winsz
This commit is contained in:
parent
cec0dafe35
commit
29fbcca987
1 changed files with 17 additions and 0 deletions
17
winsz.c
Normal file
17
winsz.c
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
#include <stdio.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main(void) {
|
||||
struct winsize w;
|
||||
|
||||
if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &w) == -1) {
|
||||
perror("ioctl");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("Rows (height): %d\n", w.ws_row);
|
||||
printf("Cols (width): %d\n", w.ws_col);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue