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

alexhutu

macrumors newbie
Original poster
Jan 28, 2012
3
0
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;
}
 
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.