I'm trying to port some existing C++ code to OS X.
The problem is that it doesn't want to load files to read from them. The code bellow illustrates this problem; when run from Finder it outputs "Failed to open input file.", however when run from Xcode it runs correctly. Thanks in advance.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
ofstream Output("Output.txt");
if(!Output.is_open())
{
cout << "Failed to open output file." << endl;
return 1;
}
Output << "Output";
Output.close();
ifstream Input("Input.txt");
if(!Input.is_open())
{
cout << "Failed to open input file." << endl;
return 1;
}
string Line;
while(!Input.eof())
{
getline(Input, Line);
cout << Line << endl;
}
return 0;
}