how can I clear the screen on a UNIX platform in C?
Printable View
how can I clear the screen on a UNIX platform in C?
If on Win32 it's system("cls"), perhaps it's system("clear") like on Linux?
It depends on how the tty is defined. For X-sessions (like Linux or Exceed) it is like Filburt1 noted. For telnet sessions on ANSI-compliant terminals this works if executed from the host:
NetTerm clears the screen by intertreting this stuff and then clears the data area of the PC Window. CRT does the same.Code:
#include <stdio.h>
#include <stdlib.h>
void main(void){
char esc = 27;
printf("%c%s",esc,"[2J");
printf("%c%s",esc,"[1;1H");
return;
For Wyse & DEC terminals this also works.
I'm sure there's something you can read under /etc that has all this information. top complains about terminal type when I run a remote session on it (it's on Solaris) via an SGI xwsh terminal (something about IRIS-ANSI-NET).