Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display C++ output in Xcode output console

Tags:

c++

xcode

I have read all prior answers to similar questions and they all seem to pertain to displaying output for a Command Line project. What if you'd like to run as what Xcode calls a 'Empty' (project with no files, targets or build configs).

The code below builds successfully. And yet the 'All Output' console still does not show the results. I tried to go deep into the GDB documentation but I'm a newbie and I get lost in it.

Below is the code:

#include <iostream>                           
using namespace std;  
int main()                                    

{                                             

cout << "Come up and C++ me some time.";  
cout << endl;                             
cout << "You won't regret it!" << endl;   
std::cout << "Press any key to continue." <<endl;
cin.get();
cin.get();

return 0;      
}

What makes it worse is that the teacher of my C++ class has no solution for this after 3 attempts.

like image 478
William Avatar asked May 09 '12 14:05

William


People also ask

How do I see the terminal output in Xcode?

Go to Xcode → Preferences → Debugging → On Start → "Show Console".

How do I print a log in Objective C?

In order to print logs, we use the NSLog method in Objective-C programming language which we have used right from the Hello World example. Now, when we compile and run the program, we will get the following result. 2013-09-16 00:32:50.888 demo[16669] Hello, World!


2 Answers

Try Activate Console command: Cmd+Shift+C or in the Top menu: View -> Debug Area -> Activate Console. It is true for Xcode 4.3.2.

As I remember there is a command Cmd+Shift+R (run in console) in Xcode 3.

like image 147
Aligus Avatar answered Oct 23 '22 12:10

Aligus


My post may be way tardy, but if any other noob users scours the web like I did for an hour before working out the answer on their own it will be a godsend. The answer was simple but no one mentioned it. Make the window wider after activating the debug area!!!

If the xcode window is too narrow, i.e. if you have a webpage open showing a tutorial on C++ and squished the xcode window next to it like I did, and you don't see the command line output despite activating the debugger because when the window is narrow the stupid xcode hides the left half of the debugger if both the right and left panels are currently visible (as is default it seems). These can be toggled off in the upper right corner. Alternatively the bottom left corner of the debugger pane has two buttons that lets you select which half of the debugger to view, the command line portion or the other portion.

If you're a noob user like me, then this just might save you an hour headache.

like image 43
had the same problem Avatar answered Oct 23 '22 12:10

had the same problem