Please help with a loading problem.
see if you can help.
char choice;
std::cin >> choice;
if (choice == ''N'' || choice == ''n''){
level = 1;
status = 0;
startprogram();
}else if (choice == ''L'' || choice == ''l''){
// Load Game
std::ifstream tfile("savegame.txt");
if (tfile.fail()){
printf("\n\n\a No Saved Game Found\n");
getoption();
}else{
//read file
tfile.close();
startprogram();
}
}else if (choice == ''C'' || choice == ''c''){
if (level == 0){
printf("\n\aError!");
getoption();
}else{
startprogram();
}
}else if (choice == ''S'' || choice == ''s''){
if (level == 0){
printf("\n\aError!");
getoption();
}else{
//Save Game
std::ofstream tfile("savegame.txt");
if (status < 10){
tfile << level << " 0" << status;
}else{
tfile << level << " " << status;
}
printf("\n\n Game Saved\n");
getoption();
}
please tell me what is going wrong, we can''t get the file to load from the saved file.
November 11, 2000 11:40 AM
choice isn''t a string, it''s a char
so
is perfectly valid
so
if (choice == ''N'' || choice == ''n'')
is perfectly valid
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement