Skip to content

Instantly share code, notes, and snippets.

@fpersson
Created January 10, 2013 20:13
Show Gist options
  • Save fpersson/4505398 to your computer and use it in GitHub Desktop.
Save fpersson/4505398 to your computer and use it in GitHub Desktop.
a quick and dirty fix.
/**
* best and easiest way... improvement can still be done ;)
*/
bool wortdateoOeffnen(){
bool openSuccess = false
string Dateiort;
cout << "Bitte die Datei inklusive Pfad angeben" << endl;
//Text noch rot machen
cout << "ACHTUNG: Bei Windows bitte / (Slash) mit \ (Backslash) austauschen " << endl << endl ;
cout << "---> ";
cin >> Dateiort;
cout << endl;
cout << endl;
ifstream file(Dateiort);
if(file.is_open() != true){
//ROT
cout << "Datei konnte nicht geoeffnet werden, bitte geben Sie einen korrekten Pfad an" << endl;
//wortdateoOeffnen(); REMOVE THIS...
}else{
cout << "Datei erfolgreich geoeffnet" << endl;
openSuccess = true; //return true if a file is open with succes
}
string buffer;
while(getline(stream, buffer)){
karten.push_back(buffer);
}
return openSuccess;
}
//-------------------------------in your main or menu------------------------//
bool fileOpen = false
while(!fileOpen){
fileOpen = wortdateoOeffnen();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment