I am using a Macbook Air. I used system("cls"); and system("clear").

That would not work. It displays on the output screen (xcode output screen) that the command cannot be found. I am using the C compiler, not C++.

How do I clear the output screen on Xcode? Please guide me through the steps in doing this.

  • 2
    This is a question more suitable for one of the programmers stack exchanges. – hotpaw2 Nov 22 '12 at 2:51
  • 2
    What do you mean by output screen, the console in Xcode or a Terminal ? – mmmmmm Nov 22 '12 at 9:36
  • The current version of Xcode (4.5.2) has an organizer window and project windows. Which of these do you consider to be the "output screen" - feel free to edit the main question and people will see your change rather than replying in comments... – bmike Nov 22 '12 at 13:40
  • Output screen = Console screen – user34476 Jan 3 '13 at 4:05

I'm not sure I entirely follow you, however; if you are using X-Code to compile and run C programs, output (e.g. any printf statements) should automatically be sent to the console, like so:

int main(int argc, const char * argv[])
   printf("Test program\n");
   return 0;

Is this the 'screen' you want to clear? If so, simply building and running any program which has no console output will do so (although I'd be interested to know why you need this.)

In the example above, comment out the line with the printf statement and build and run. You'll get a clear console.

| improve this answer | |
  • I would just like to clear the output screen on Xcode. And yes, just a simple printf example is okay. Could you also tell me how I can display the output screen on Terminal? – user34476 Nov 27 '12 at 23:37
  • I use system("cls"); at school and it works fine but it does not clear the screen. Instead, it says it is not a function or it cannot be found. – user34476 Nov 27 '12 at 23:39
  • I used printf("Hello World!\n"); then the line after that system("clear"); then in bold letters it displays "TERM environment variable not set." What does that mean? – user34476 Nov 27 '12 at 23:59
  • Redirecting console output to the terminal is not something I've ever had call to do. However, according to an answer on [stackoverflow.com/questions/1910177/… it is possible. – Robert Nov 28 '12 at 9:00

It seems as though it is not possible to clear the output screen with any function on Xcode. I installed Visual Studio 6 on my Windows XP and the system("cls"); function works. Thank you everyone for helping me with this issue.

| improve this answer | |

You can also try something that is not so system specific. Try using ANSI escape codes to clear your screen:

You can also try something like this, which clears the entire screen:


You can include \0333[1;1H to be sure if \0333[2J does not move the cursor in the upper left corner.

More specifically:

  • 033 is the octal of ESC
  • 2J is for clearing the entire console/terminal screen (and moves cursor to upper left on DOS ANSI.SYS)
  • 1;1H moves the cursor to row 1 and column 1
| improve this answer | |