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

Thread Tools Search this Thread Display Modes
Old Mar 1, 2012, 07:54 AM   #1
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("");
ofstream out("test.out");
out<<"a+b= "<<a+b;
alexhutu is offline   0 Reply With Quote
Old Mar 1, 2012, 03:45 PM   #2
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
macrumors 603
Join Date: Aug 2009
This thread shows where to set the Working Directory in Xcode 4:

If you're not using Xcode 4, please identify your Xcode version.
chown33 is offline   0 Reply With Quote

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
How to create and use input/output files with Xcode C++ hotglass Mac Programming 14 Feb 6, 2012 10:53 PM
Learning how to use Xcode / interface builder to program in c/++ furycd001 Mac Programming 6 Sep 20, 2011 04:45 AM
Help: How to read Mac Excel 2008 files with WinXP Excel 2003 MacGiver Mac Basics and Help 1 May 4, 2008 05:16 PM
how to use an external hard drive with mac and pc? mversion Mac Basics and Help 2 Jul 17, 2006 07:52 PM

All times are GMT -5. The time now is 08:37 AM.

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

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