How to check ymax and xmax in a console window, under Windows, using plain c?
There is this piece of code for linux:
#include <stdio.h>
#include <sys/ioctl.h>
int main (void)
{
struct winsize max;
ioctl(0, TIOCGWINSZ , &max);
printf ("lines %d\n", max.ws_row);
printf ("columns %d\n", max.ws_col);
}
Now I wonder how can I do the same for windows. I tried winioctl.h
but it does not define struct winsize
nor any other with a similar name.
Any tips? Thanks.
PS. In linux you also can find the console size using getenv("LINES");
. Is there a similar variable under windows?
PPS. Also, there is always ncurses.h
, that I suppose work both systems, but I'm avoiding it because of conflicts with other libraries I have.
PPPS. This question here Getting terminal width in C? has a lot of tips, so no need to repeat that.