How to use C++ <fstream> output files with Xcode?

Discussion in 'Mac Programming' started by alexhutu, Mar 1, 2012.

  1. alexhutu macrumors newbie

    Jan 28, 2012
    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;
  2. ScoobyMcDoo macrumors 65816

    Nov 26, 2007
    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.
  3. chown33 macrumors 604

    Aug 9, 2009
    Sailing beyond the sunset

Share This Page