Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I successfully am able to run a Hello World program in C++, but I can't see and output. Where is it?

Tags:

c++

xcode

I am a complete beginner. I just downloaded xCode today. Here is a screenshot of what I have:

enter image description here

As you can see, I successfully ran the program, however, I can't see any out put anywhere. Where is it and how do I see it?

like image 648
user1443548 Avatar asked Jun 08 '12 02:06

user1443548


2 Answers

It does not look like the program has run at all, only built. The status up at the top says build succeeded, not run succeeded. Command-R will run the program.

Here is what it will look like when you run the program: Finished running

Also you can use the Log Navigator to go and see results from previous build and debug sessions. Log Navigator

You will often see tutorial programs written for Windows where the program ends with asking the user for input. The reason for this is that the console model on Windows has the program owning the console window, so the window will disappear as soon as the program exits. So by asking for input as the last thing the program will keep running until the user gives it that input, whereupon it the program will complete and the console window will disappear.

Non-Windows platforms don't behave this way and generally do not require such code.

like image 78
bames53 Avatar answered Nov 14 '22 21:11

bames53


Put a breakpoint at the return statement or a getchar() before return. The reason you're not seeing the output is because the console closes when the program exits. So the above points prevent the program from ending.

like image 45
Superman Avatar answered Nov 14 '22 22:11

Superman