Created
January 10, 2013 20:13
-
-
Save fpersson/4505398 to your computer and use it in GitHub Desktop.
a quick and dirty fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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