Size of Terminal wi...
 
Notifications
Clear all

Size of Terminal window

3 Posts
3 Users
1 Likes
444 Views
(@hamraz12)
New Member
Joined: 5 years ago
Posts: 3
Topic starter  

Hello,

May I ask how may we get the size of terminal window? so we can print the messages in right and left side of window.

after that task just the next message must be printed like that or all next messages also must be like that (left and right side)?

thanks


   
Quote
(@kokavec_ondrej)
Active Member
Joined: 5 years ago
Posts: 14
 

The classic size of terminal window is 25×80 (lines x columns), but you counting coordinates from 0.

And the whole communication with server (from start to end) must be set like this.

Hope it helps.


   
ReplyQuote
(@polex)
New Member
Joined: 5 years ago
Posts: 4
 

Hi, here is one program for calculating the number of rows and columns of your terminal window. Classic size is, like Ondrej said, 25x80, but mine has 30x120 so I hope this will be helpful.

#include <windows.h>

int main(int argc, char *argv[]) {
    CONSOLE_SCREEN_BUFFER_INFO csbi;
    int columns, rows;

    GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi);
    columns = csbi.srWindow.Right - csbi.srWindow.Left + 1;
    rows = csbi.srWindow.Bottom - csbi.srWindow.Top + 1;

    printf("columns: %d\n", columns);
    printf("rows: %d\n", rows);
    return 0;
}

   
ReplyQuote
Share:
Close Menu