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 Mar 1, 2012, 07:54 AM   #1
alexhutu
macrumors newbie
 
Join Date: Jan 2012
How to use C++ <fstream> output files with Xcode?

I am learning C++ at school, but I have a Mac and I just started using Xcode. I use the fstream library.
I need to know where the ".out" file is located or how to create it.
I managed to create the input file and if I use "cout" to display the result it works. Hope I explained everything well, here is a very basic program to show you what I mean:

#include <fstream>
using namespace std;
int main()
{
int a,b;
ifstream in("test.in");
ofstream out("test.out");
in>>a>>b;
out<<"a+b= "<<a+b;
}
alexhutu is offline   0 Reply With Quote
Old Mar 1, 2012, 03:45 PM   #2
ScoobyMcDoo
macrumors 65816
 
Join Date: Nov 2007
Location: Austin, TX
Your code creates the output file. In this case, it will be created in the folder from which you run the program. If you are running it from within Xcode, you can set your working directory, or use the default. I'm not sure where the default location is.
ScoobyMcDoo is offline   0 Reply With Quote
Old Mar 1, 2012, 05:05 PM   #3
chown33
macrumors 603
 
Join Date: Aug 2009
This thread shows where to set the Working Directory in Xcode 4:
http://forums.macrumors.com/showthread.php?t=1285568

If you're not using Xcode 4, please identify your Xcode version.
chown33 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
Xcode file output xcodeROOKIE Mac Programming 5 Oct 4, 2013 02:52 PM
QT won't play HB output files dshlapak Apple TV and Home Theater 14 Mar 27, 2013 08:17 AM
After updating XCode, output terminal problem iMacFarlane Mac Programming 9 Oct 3, 2012 11:29 PM
Input/Output with files in XCode crisro996 Mac Programming 2 Jul 21, 2012 12:20 PM

Forum Jump

All times are GMT -5. The time now is 02:56 AM.

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

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