#include #include #include int main(int argc, char * argv[]) { struct winsize w; int width, height; ioctl(0, TIOCGWINSZ, &w); width = w.ws_col; height = w.ws_row; printf("Terminal is %dx%d\n", width, height); }