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

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

  1. Bruki macrumors newbie

    Bruki

    Joined:
    Feb 12, 2008
    #1
    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
     
  2. Cromulent macrumors 603

    Cromulent

    Joined:
    Oct 2, 2006
    Location:
    The Land of Hope and Glory
    #2
    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, http://www.cprogramming.com/ is a very good site for C++ and should get you started.
     
  3. lee1210 macrumors 68040

    lee1210

    Joined:
    Jan 10, 2005
    Location:
    Dallas, TX
    #3
    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.
     
  4. Bruki thread starter macrumors newbie

    Bruki

    Joined:
    Feb 12, 2008
  5. rev316 macrumors regular

    Joined:
    Nov 7, 2004
    #5
    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