4 Replies - 12392 Views - Last Post: 23 March 2009 - 09:14 PM Rate Topic: -----

#1 Twimfy  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 18-March 09

No output in Xcode

Posted 18 March 2009 - 11:29 AM

Hi, this is my first post on this site and I am looking forward to learning a lot from it.

Anyhoo I've been wanting to learn C++ for years and now that I have a bit of time on my hands I figured I'd start. I've recently moved to Mac OS X and so it seems to make sense to use Xcode for most of my learning process (I intend to dabble with the iPhone SDK eventually).

I have been using this tutorial http://kknapp.sd38.c...P/03_intro.html and although I am starting to understand a lot of the concepts, putting them into practice isn't as easy simply because I cannot get any output.

I am following the tutorial to the letter and yet when the author states 'check your output' I have no output, there is no run log or any new window opening. I understand that he is using an older version of the SDK whereas mine is 3.1.2 but it shouldn't make to much difference.

This is my code
#include <iostream>

int main (int argc, char * const argv[]) {
	std::cout << "Hello, Tim!\n";
	return 0;
}


Please help me find the solution, I'm 99% sure it's something simple.

Is This A Good Question/Topic? 0
  • +

Replies To: No output in Xcode

#2 OliveOyl3471  Icon User is offline

  • Everybody's crazy but me!
  • member icon

Reputation: 134
  • View blog
  • Posts: 6,581
  • Joined: 11-July 07

Re: No output in Xcode

Posted 18 March 2009 - 11:43 AM

I would think that your problem is that you are actually getting output, but the screen flashes by so fast you cannot read it.
Try this:

#include <iostream>

int main (int argc, char * const argv[]) {
	std::cout << "Hello, Tim!\n";
	system("Pause");   //pause screen so we can read output
	return 0;
}


Also if you put this line directly above int main, then you will not need to put the std:: part before cout
using namespace std;

:)

p.s. here's a whole discussion about holding the execution window open, and the other (better) options you can use instead of system("Pause"); even though system("Pause") will work.

http://www.dreaminco...wtopic30581.htm

This post has been edited by OliveOyl3471: 18 March 2009 - 11:45 AM

Was This Post Helpful? 0
  • +
  • -

#3 erik.price  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 485
  • View blog
  • Posts: 2,690
  • Joined: 18-December 08

Re: No output in Xcode

Posted 18 March 2009 - 11:48 AM

I'm using a Mac too. I am almost positive that system("PAUSE") doesn't work on Mac systems. It doesn't work for me at least.

You should probably use getchar() or cin.get() or, if that doesn't work definitely check out the link OliveOyl gave.
Was This Post Helpful? 0
  • +
  • -

#4 crazyjugglerdrummer  Icon User is offline

  • GAME OVER. NERD WINS.
  • member icon

Reputation: 119
  • View blog
  • Posts: 690
  • Joined: 07-January 09

Re: No output in Xcode

Posted 18 March 2009 - 05:17 PM

Correct, mac doesn't like the most of the system commands. If you are going to dabble in the iphone some day, you'll eventually need to look at objective C, which is C with different OO extensions. It's easy enough after C++ though, here's some stuff on that. Happy coding!
Was This Post Helpful? 0
  • +
  • -

#13 daheado  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 1
  • Joined: 23-March 09

Re: No output in Xcode

Posted 23 March 2009 - 09:14 PM

View PostTwimfy, on 18 Mar, 2009 - 10:29 AM, said:

Hi, this is my first post on this site and I am looking forward to learning a lot from it.

Anyhoo I've been wanting to learn C++ for years and now that I have a bit of time on my hands I figured I'd start. I've recently moved to Mac OS X and so it seems to make sense to use Xcode for most of my learning process (I intend to dabble with the iPhone SDK eventually).

I have been using this tutorial http://kknapp.sd38.c...P/03_intro.html and although I am starting to understand a lot of the concepts, putting them into practice isn't as easy simply because I cannot get any output.

I am following the tutorial to the letter and yet when the author states 'check your output' I have no output, there is no run log or any new window opening. I understand that he is using an older version of the SDK whereas mine is 3.1.2 but it shouldn't make to much difference.

This is my code
#include <iostream>

int main (int argc, char * const argv[]) {
	std::cout << "Hello, Tim!\n";
	return 0;
}


Please help me find the solution, I'm 99% sure it's something simple.



View PostTwimfy, on 18 Mar, 2009 - 10:29 AM, said:

Hi, this is my first post on this site and I am looking forward to learning a lot from it.

Anyhoo I've been wanting to learn C++ for years and now that I have a bit of time on my hands I figured I'd start. I've recently moved to Mac OS X and so it seems to make sense to use Xcode for most of my learning process (I intend to dabble with the iPhone SDK eventually).

I have been using this tutorial http://kknapp.sd38.c...P/03_intro.html and although I am starting to understand a lot of the concepts, putting them into practice isn't as easy simply because I cannot get any output.

I am following the tutorial to the letter and yet when the author states 'check your output' I have no output, there is no run log or any new window opening. I understand that he is using an older version of the SDK whereas mine is 3.1.2 but it shouldn't make to much difference.

This is my code
#include <iostream>

int main (int argc, char * const argv[]) {
	std::cout << "Hello, Tim!\n";
	return 0;
}


Please help me find the solution, I'm 99% sure it's something simple.



View Postcrazyjugglerdrummer, on 18 Mar, 2009 - 04:17 PM, said:

Correct, mac doesn't like the most of the system commands. If you are going to dabble in the iphone some day, you'll eventually need to look at objective C, which is C with different OO extensions. It's easy enough after C++ though, here's some stuff on that. Happy coding!


in Xcode click run then Console. Your output is there.
Was This Post Helpful? 1

Page 1 of 1