Megaerikivan

Como saber el ancho y alto de la terminal de linux en C

Feb 10th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.32 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3.  
  4. #include<sys/ioctl.h>
  5. #include<unistd.h>
  6.  
  7. #define Alto  X.ws_row
  8. #define Ancho X.ws_col
  9.  
  10. void main(){
  11.  
  12. struct winsize X;
  13.  
  14.  
  15. for(;;){
  16.         ioctl(0, TIOCGWINSZ, &X);
  17.         printf("Alto:\t%i\nAncho:\t%i\n\n", Alto, Ancho);
  18.         sleep(1);
  19.         system("clear");
  20. }
  21.  
  22.  
  23. }
Add Comment
Please, Sign In to add comment