One way to determine the number of rows and columns on a UNIX system within a C program is to use the ioctl system call. Here is a program that demonstrates how this is done. This would be useful if you implement any program that uses an X window as an ascii screen, and needs to know the size of the screen. This is not relevant to determining the number of rows and columns of pixels in the X-windows, but rather the number of rows and columns of text.
---------------------------- #include <stdio.h> #include <sys/ioctl.h>
main() { struct winsize win; ioctl(1,TIOCGWINSZ, &win); printf("%d rows and %d columns\n", win.ws_row, win.ws_col); } -----------------------------
This might need some mods for Linux.