I am trying to open a file which normally has content, for the purpose of testing i will like to initialize the program without the files being available/existing so then the program should create empty ones, but am having issues implementing it. This is my code originally
void loadFiles() {
fstream city;
city.open("city.txt", ios::in);
fstream latitude;
latitude.open("lat.txt", ios::in);
fstream longitude;
longitude.open("lon.txt", ios::in);
while(!city.eof()){
city >> cityName;
latitude >> lat;
longitude >> lon;
t.add(cityName, lat, lon);
}
city.close();
latitude.close();
longitude.close();
}
I have tried everything i can think of, ofstream, ifstream, adding ios::out
all all its variations. Could anybody explain me what to do in order to fix the problem. Thanks!