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

funnie

macrumors newbie
Original poster
Jan 20, 2007
1
0
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.

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

2.
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!
 

lazydog

macrumors 6502a
Sep 3, 2005
709
6
Cramlington, UK
Hi

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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.