I am writing a small application in C and want to clear the terminal/dos window of text.
So far I have:
if (system("cls"))
system("clear");
Which seems to work fine on just about开发者_StackOverflow everything except Mac, which gives me the error:
sh: cls: command not found TERM environment variable not set.
Whats weird, is that clear
from the terminal works, but not system(clear);
and I am not sure why.
Does anyone know how I can stop this, or modify my code to clear the screen on a Mac terminal which will work on other ANSI C compliant compilers, without, obviously, writing a bunch of '/n's to the console?
It turns out this is a problem with compiling and running inside XCode. When compiled and run outside XCode, the code works as expected. Doh!
精彩评论