Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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.

share|improve this question

closed as off-topic by patrix May 7 at 9:39

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about software development are off-topic here, but can be asked on Stack Overflow." – patrix
If this question can be reworded to fit the rules in the help center, please edit the question.

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 ? –  Mark 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 –  Eugene Jan 3 '13 at 4:05

3 Answers 3

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");
   getchar();
   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.

share|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? –  Eugene 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. –  Eugene 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? –  Eugene 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
up vote 2 down vote accepted

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.

share|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:

printf("\033[2J\033[1;1H");

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
share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.