Is there any way to force a program to shut down without using code to make it crash (or using a while loop)? If the answer is in a tutorial on this site, please tell me which tutorial and I'll find it myself. The reason I want this is to shut down the program when it fails to load a file, preventing the program from screwing up by calling data from a file that doesnt exist, or is corrupted, damaged etc. If there isn't any way to do this please tell me. I'll use the while loop if I have to, but I thought there might be a quicker and easier way to do it.
EDIT: I have another problem. I just wrote this switch-case bit and Dev C++ is telling my that there are undeclared functions (n, l, and y)
I havent actually put in the code between the case and break sections yet, but as far as I can tell, I don't have any errors in it. I'm also getting a "Warning: Unreachable code at beginning of switch statement" error that I don't understand. I know it's a lot of questions, but I can't find my error, so I need help. Yes, I did check the Switch-Case tutorial but as far as I can tell, I haven't made an error.Code:cout<<"Would you like to create a new data file or load an existing one.\n"; cout<<"[N]ew or [L]oad (Capitalized)\n"; cin>> newload; cin.ignore(); switch ( newload ) { case n: cout<<"Are you sure? Saved data will be Erased.\n"; cout<<"[Y]es or [N]o (Capitalized)\n"; cin>> sure; cin.ignore(); switch ( sure ) { case y: break; case n: //This is where i want to put the "End program" statement if I can break; default: break; } break; case l: break; default: break; }



LinkBack URL
About LinkBacks



I used to be an adventurer like you... then I took an arrow to the knee.