View Full Version : Newbie C++ in Xcode

Jan 21, 2007, 01:16 AM
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!

Jan 21, 2007, 05:10 AM

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

Jan 25, 2007, 12:40 PM
Don't forget to indent and comment your code.

Good luck with your class!