| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
#include <sys/ioctl.h> int ioctl(int fd, int cmd, ... ); |
Otherwise,the operation specified by cmd is performed on the file open on handle fd. The following operations are defined by the header `sys/ioctl.h':
TIOCGWINSZ
winsize structure pointed to by the third argument
with the screen width and height.
The winsize structure is defined in `sys/ioctl.h'
as follows:
struct winsize
{
unsigned short ws_row; /* rows, in characters */
unsigned short ws_col; /* columns, in characters */
unsigned short ws_xpixel; /* horizontal size, pixels */
unsigned short ws_ypixel; /* vertical size, pixels */
};
|
TIOCGWINSZ. Otherwise, -1 is returned and errno is set
to ENOSYS for all others.
#include <sys/ioctl.h>
#include <stdio.h>
int main(int argc, char **argv)
{
struct winsize sz;
ioctl(0, TIOCGWINSZ, &screen_size);
printf("Screen width: %i Screen height: %i\n", sz.ws_col, sz.ws_row);
return 0;
}
|