So im in some tutorials that involve file making through c++ using fstream. Simple stuff, and i believe my code works correctly, the problem is that im using a mac therefore making the folder .txt wont work (I am using Xcode for my IDE in case that helps. Would anyone happen to know what format i can use to make simple text folders like i would for windows using .txt?
#include <iostream>
#include <fstream>
usingnamespace std;
int main()
{
ofstream theFile("players.txt");//The code runs successfully, but no folder is made because i dont think mac has a .txt folder type :S
cout << "Enter player's ID, Name, and Money" << endl;
cout << "press Ctrl+Z to quit\n" << endl;
int id;
string name;
double money;
while(cin >> id >> name >> money)
{
theFile << id << ' ' << name << ' ' << money << endl;
}
return 0;
}
I couldnt find any answers online so maybe ill just have to do these tutorials without practice?
txt isn't a folder, it is a file extension. I would guess that XCode is putting that file in a weird place, but someone with a mac would have to help you there.
I would suggest building/running your programs from the command line, it will be a good skill to have. I would also guess that the output file would be in a more apparent place.
txt isn't a folder, it is a file extension. I would guess that XCode is putting that file in a weird place, but someone with a mac would have to help you there.
In the Xcode menu, click on Preferences...
In the dialogue box, click on Locations
Look for where the derived data path leads and have a look there.