Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Bruki

macrumors newbie
Original poster
Feb 12, 2008
5
0
Hi,

I am trying to learn programming in C++ with xcode I have no prior programming knowledge & I am learning from online tutorials.

The first lessons is very basic this is the command:

#include <iostream>

using namespace std;

int main()
{
cout<<"HEY, you, I'm alive! Oh, and Hello World!\n";
cin.get();
}

I did a little research online & found I should be building in C++TOOL

so I launched this & opened the main.cpp file, I deleted what was inside & replaced it with the command above.

I then clicked Build & Go, it asked me to save so I did & then it seemed to run fine (it said Success in the bottom right corner) but nothing happened?

no window showed up, no text was displayed, nothing.

am I doing something very stupid or do I have a problem somewhere.

any help would be much appreciated & as I'm new to this board & new to programming.

Thank You
 

lee1210

macrumors 68040
Jan 10, 2005
3,182
3
Dallas, TX
In XCode:
Window -> Tools -> Run Log

Things written to stdout should show up there.

For this and many other reasons I recommend, when you're first starting out, building from the command line. Get an editor like Textmate or Textwrangler (or use vim from the command line, but people seem to balk at learning vi) and put your code in there. Save it as something like test.cpp. Then from the terminal, in the directory you saved the source file:

Code:
g++ -o test test.cpp

This means run the program g++ with the output (your program) being called test.

To run your program, run:
Code:
./test

All the stdout will be written to your present window.

I really think this is best when you are first learning.

Good luck!

-Lee

edit: Crom beat me. Stupid microwave beep.
 

rev316

macrumors regular
Nov 7, 2004
156
0
I completely agree with Cromulent. Start with a strong foundation and then move yourself to the IDEs. It can get overwhelming at first, but it'll click the more you move along in learning.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.