Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jul 21, 2012, 10:10 AM   #1
crisro996
macrumors newbie
 
Join Date: Jul 2012
Input/Output with files in XCode

Hi there, I'm trying to learn C++ on Mac or actually learn to use XCode

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 by crisro996; Jul 21, 2012 at 10:17 AM.
crisro996 is offline   0 Reply With Quote
Old Jul 21, 2012, 12:09 PM   #2
chown33
macrumors 603
 
Join Date: Aug 2009
Quote:
Originally Posted by crisro996 View Post
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.

Quote:
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.
chown33 is offline   0 Reply With Quote
Old Jul 21, 2012, 12:20 PM   #3
crisro996
Thread Starter
macrumors newbie
 
Join Date: Jul 2012
Quote:
Originally Posted by chown33 View Post
That's not a full path, so it won't work. Please post what you actually used.


You should study what working directory and relative path means.

Then learn how to change your working directory in Xcode.
Thank you, worked perfectly. Thanks for those links as well, very interesting.
crisro996 is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Xcode build phase - unknown number of input files to unknown number of output files TheChekt Mac Programming 0 Dec 15, 2013 08:42 AM
How do I change audio output to input? abhithegreat MacBook Pro 2 Jul 27, 2013 04:07 PM
Audio input to output app? Mubanga Mac Applications and Mac App Store 1 Mar 4, 2013 05:07 PM
My solution for "No Sound Output to MacBook Speakers" - Re-route Sound Input / Output grantdoug MacBook Pro 1 Jun 27, 2012 10:44 AM

Forum Jump

All times are GMT -5. The time now is 11:42 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC