简体   繁体   中英

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

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

在此输入图像描述

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?

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: 跑完了

Also you can use the Log Navigator to go and see results from previous build and debug sessions. 日志导航器

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM