Created
April 14, 2017 02:05
-
-
Save sbz/4ba35bdaf51629216dbce84636a4cccf to your computer and use it in GitHub Desktop.
get terminal size using ioctl get win size (TIOCGWINSZ) in C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <sys/ioctl.h> | |
#include <stdio.h> | |
#include <unistd.h> | |
int | |
main(void) { | |
struct winsize ws; | |
ioctl(STDIN_FILENO, TIOCGWINSZ, &ws); | |
printf ("lines %d\n", ws.ws_row); | |
printf ("columns %d\n", ws.ws_col); | |
return (0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks!!!