Hi,
How can I know the number of lines of the screen when working in a text environment (non X Windows).
Thanks in advance
Printable View
Hi,
How can I know the number of lines of the screen when working in a text environment (non X Windows).
Thanks in advance
You can't - in standard C anyway.
You could try using a library like ncurses, but that adds quite a bit to your code.
First question is, why do you want to know?
Without messing around with terminal calls, most modern unix shells
(POSIX (sh) and Korn (ksh) ) support the LINES variable
A crude hack:
This is not something to call repeatedly, it creates a process, so is slowCode:#include <stdio.h>
int MAX_LINES(void) // number of terminal lines
{
char tmp[24]={0x0};
FILE *p=popen("echo $LINES","r");
fgets(tmp,sizeof(tmp),p);
return atoi(tmp);
}
why not just use getenv("LINES");
moi - yes.