New To Programing, xcode & C++ Need a Little Help

Discussion in 'Mac Programming' started by Bruki, May 18, 2008.

  1. Bruki macrumors newbie


    Feb 12, 2008

    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";

    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
  2. Cromulent macrumors 603


    Oct 2, 2006
    The Land of Hope and Glory
    Do not use Xcode to start with. Use the command line, it is much simpler. Xcode just adds another layer of complexity to the whole process.

    As for sites, is a very good site for C++ and should get you started.
  3. lee1210 macrumors 68040


    Jan 10, 2005
    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:

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

    To run your program, run:
    All the stdout will be written to your present window.

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

    Good luck!


    edit: Crom beat me. Stupid microwave beep.
  4. Bruki thread starter macrumors newbie


    Feb 12, 2008
  5. rev316 macrumors regular

    Nov 7, 2004
    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.

Share This Page