szaydel
10/24/2018 - 4:19 AM

Get terminal size via IOCTL

Get terminal size via IOCTL

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

int
main(void) {
	struct winsize ws;
	ioctl(STDIN_FILENO, TIOCGWINSZ, &ws);
  // ws.ws_row => nrows
  // ws.ws_col => ncols
}