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

crisro996

macrumors newbie
Original poster
Jul 11, 2012
6
0
Hi there, I'm trying to learn C++ on Mac or actually learn to use XCode :D

I have managed to get input/output with working, but after giving the full path of the file I was writing in/reading from:
Code:
ifstream f("users/.../data.in")

My question is, how can I just give the location as data.in.
Code:
ifstream f("data.in")
I've been studying C++ on Windows until now and it's really simple in MS VC++, you just put the name of the file and you're good to go.
 
Last edited:

chown33

Moderator
Staff member
Aug 9, 2009
10,740
8,416
A sea of green
I have managed to get input/output with working, but after giving the full path of the file I was writing in/reading from:
Code:
ifstream f("users/.../data.in")

That's not a full path, so it won't work. Please post what you actually used.

My question is, how can I just give the location as data.in.
Code:
ifstream f("data.in")
I've been studying C++ on Windows until now and it's really simple in MS VC++, you just put the name of the file and you're good to go.
You should study what working directory and relative path means.

Then learn how to change your working directory in Xcode.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.