Newbie C++ in Xcode

Discussion in 'Mac Programming' started by funnie, Jan 20, 2007.

  1. funnie macrumors newbie

    Jan 20, 2007
    Hi everyone,

    i am taking a beginner course in C++ programming but my course uses software in the windows environment.

    I know this has come up many times, but i do appreciate if anyone could clarify things.

    I use Xcode.
    Is the correct project to create called ( C++ Tool ) under the Command Line Utility?

    I have some basic code that works in windows but not on my mac.
    This program copies the contents of a file and outputs a new file.
    #include <fstream>
    #include <string>

    int main()

    ifstream infile("in");
    ofstream outfile("out");
    string s;
    while (getline(infile,s))
    outfile << s << endl;

    return 0;

    Is something fundamentally wrong with my code? Or is it different on MAC?

    Thanks a lot!
  2. lazydog macrumors 6502a

    Sep 3, 2005
    Cramlington, UK

    Yes, C++ tool is the right project for what you are trying to do.

    Try putting:-

    using namespace std ;

    after your #includes.

    Or specify the namespace directly, eg std::ifstream infile("in");

    b e n
  3. LtRammstein macrumors 6502a


    Jun 20, 2006
    Denver, CO
    Don't forget to indent and comment your code.

    Good luck with your class!


Share This Page