Hello! I am attempting to write a simple console application that reads from a text file and then generates a random sentence based on the rules/words in the text file. The program works just fine on my windows machine, and, because I didn't include a file path for the input file, it just looks for it in what ever folder the application is in, which makes it really easy to move to a different computer (where the file path would be different) to show someone else. However, when I tried to recompile it on my mac, in Xcode, the application can't read the text file, even though I put the text file in the folder with the application (in the DerivedData/ProgramName/Build/Products/Debug folder). If I just run the program in Xcode the program reads the data file just fine, but the standalone application can't. Any ideas?
Relevant portion of my program:
Thanks for your help!
Relevant portion of my program:
Code:
vector<string> s;
ifstream data;
data.open("default.txt");
if(!data)
{
cerr << "Could not open input file.\n";
consolePause();
exit(1);
}
string line;
while (getline(data, line))
{
s.push_back(line);
}
data.close();
Thanks for your help!