Created
November 25, 2015 06:59
-
-
Save NickersF/2e094fbb87b4b774fa73 to your computer and use it in GitHub Desktop.
C++ - Generic function which closes a win32 console application
This file contains 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
// A generic function to close win32 console applications | |
#include <iostream> | |
#include <iomanip> | |
#include <fstream> | |
#include <string> | |
using namespace std; | |
void closeApp(); | |
int main() { | |
closeApp(); | |
return 0; | |
} | |
// application termination function | |
void closeApp() { | |
// local variables | |
bool inputSafe = false; | |
string reply; | |
string accept = "q"; | |
while (!inputSafe == true) { | |
cout << "Please enter q to exit the application: "; | |
cin.clear(); | |
getline(cin, reply); | |
if (reply == accept) { | |
inputSafe = true; | |
exit(1); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment