6

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.

3
  • Have you tried running it from the command line? May 9, 2012 at 14:48
  • I wouldn't blame your teacher, it's not their job to use every IDE.
    – 111111
    May 9, 2012 at 14:49
  • @David Yes, I have tried and it works as command line. When I run the following code I do get output in 'All Output' console. But I'd like to be able to run this as a Empty Project. Is that possible? #include <iostream> int main (int argc, const char * argv[]) { using namespace std; cout << "Come up and C++ me some time."; cout << endl; cout << "You won't regret it!" << endl;cout << "Press any key to continue." <<endl; cin.get(); return 0; }
    – William
    May 9, 2012 at 15:05

4 Answers 4

8

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.

6
  • The console is active. Just no output in the output console.
    – William
    May 9, 2012 at 15:12
  • Did you start program by cmd+R?
    – Aligus
    May 9, 2012 at 15:13
  • when I hit cmd+R I get a chime. nothing happens.
    – William
    May 9, 2012 at 15:28
  • 2
    Try to create new project: Mac OS X -> Application -> Command Line Tool -> Type: C++. It works ok on my mac.
    – Aligus
    May 9, 2012 at 17:25
  • 2
    Yes. Creating a new project as a Command Line Tool and using the same code works just fine. But as I pointed out to David above, I am trying to Create a new project using the Xcode 'Empty Project' Template. Have you been able to do this and create output that shows in output console?
    – William
    May 10, 2012 at 4:41
1

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.

1

Few things first.

Xcode is used for multitude of development from mobile-app to a basic console application(which as I understand is your case).

Xcode knows to associate I/O with your OSX/Xcode console when you create a New Project -> template of OS X -> application and console. (the OSX console may be default I/O for number of other framework, but obviously is the default one for the above).

Another important thing(which you are already doing) as someone mentioned. Xcode does not log to console until it sees "endl" or "\n" .

-1

It seems you have to have "\n" at the end of your prints. Like so:

cout << "Come up and C++ me some time.\n";

That should sort it.

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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