Garey

get console size

Nov 29th, 2017
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.40 KB | None | 0 0
  1. #include <windows.h>
  2.  
  3. int main(int argc, char *argv[])
  4. {
  5.     CONSOLE_SCREEN_BUFFER_INFO csbi;
  6.     int columns, rows;
  7.  
  8.     GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
  9.     columns = csbi.srWindow.Right - csbi.srWindow.Left + 1;
  10.     rows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;
  11.  
  12.     printf("columns: %d\n", columns);
  13.     printf("rows: %d\n", rows);
  14.     return 0;
  15. }
Add Comment
Please, Sign In to add comment