The previous post assumes you are using Unix. On Windows, you can clear the screen by using the "cls" command; there is no "clear" command on Windows. I was able to use the following code to clear the screen (command window) using Borland C++ 5.5.1 for Win32 on Windows XP:
Code:
#include <iostream>
int main( int argc, char *argv[] )
{
system("cls");
}
You can use the following C statement to clear your screen:
Code:
system("sh -c clear");
You are executing the sh shell program (usually /bin/sh) and having it execute the built-in "clear" command. You need to use the "-c" option to tell sh that the next option is a built-in command, not a file to be executed. See the man page on sh for more info.
Leave a comment: