How to resize the console window using C

The code for resizing the console window is given below

The code for resizing the console window is given below

#include <stdlib.h>
#include <stdio.h>
#include <windows.h>
HANDLE wHnd;    // Handle to write to the console.
HANDLE rHnd;    // Handle to read from the console.
int main(int argc, char* argv[]) {
    // Set up the handles for reading/writing:
    wHnd = GetStdHandle(STD_OUTPUT_HANDLE);
    rHnd = GetStdHandle(STD_INPUT_HANDLE);
    // Change the window title:
    SetConsoleTitle("Advanced C tutorial - programming-technique.blogspot.com");
    // Set up the required window size:
    SMALL_RECT windowSize = {0, 0, 50, 10};
    SetConsoleWindowInfo(wHnd, 1, &windowSize);
    // Change the console window size:
        // Create a COORD to hold the buffer size:
    COORD bufferSize = {10, 10};
    SetConsoleScreenBufferSize(wHnd, bufferSize);
    // Exit
    return 0;
}
SHARE How to resize the console window using C

You may also like...

3 Responses

  1. Anonymous says:

    Good job!

  2. Anonymous says:

    Hey how do i prevent a user from resizing console window in c

Leave a Reply

Your email address will not be published.

Share