Advertisement
Guest User

Untitled

a guest
Nov 25th, 2015
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. // A generic function to close win32 console applications
  2.  
  3. #include <iostream>
  4. #include <iomanip>
  5. #include <fstream>
  6. #include <string>
  7.  
  8. using namespace std;
  9.  
  10. void closeApp();
  11.  
  12. int main() {
  13.  
  14. closeApp();
  15. return 0;
  16. }
  17.  
  18. // application termination function
  19. void closeApp() {
  20. // local variables
  21. bool inputSafe = false;
  22. string reply;
  23. string accept = "q";
  24.  
  25. while (!inputSafe == true) {
  26. cout << "Please enter q to exit the application: ";
  27. cin.clear();
  28. getline(cin, reply);
  29. if (reply == accept) {
  30. inputSafe = true;
  31. exit(1);
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement