/* *@author cody *@date 2014-08-12 *@description */ /* #include <sys/ioctl.h> send control and config order to device int ioctl(int d,int request,...); params d -- file descriptor request ---ioctl order */ #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/ioctl.h> void GetTernimalSize(){ struct winsize size; if(isatty(STDOUT_FILENO) == 0){ exit(1); } if(ioctl(STDOUT_FILENO,TIOCGWINSZ,&size) < 0){ perror("ioctl error"); exit(1); } printf("%d rows,%d columns ",size.ws_row,size.ws_col ); } int main(int argc, char const *argv[]) { GetTernimalSize(); return 0; }