Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

terminal size in c

#include <sys/ioctl.h>
#include <stdio.h>
#include <unistd.h>

int main (int argc, char **argv)
{
    struct winsize w;
    ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);

    printf ("lines %d
", w.ws_row);
    printf ("columns %d
", w.ws_col);
    return 0;  // make sure your main returns int
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #terminal #size
ADD COMMENT
Topic
Name
6+2 =