Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <windows.h>
  4.  
  5.  
  6. using namespace std;
  7.  
  8. void mainfunc(){
  9.  
  10. int something=1;
  11. int somethingelse=2;
  12.  
  13. int arandomvalue=something+somethingelse;
  14.  
  15. cout << arandomvalue;
  16.  
  17. }
  18.  
  19. int retry(){
  20.  
  21.  
  22. //string Typedinletter;
  23.  
  24. char buffer[2];
  25. //the second element is to hold the newline that the console should put on
  26.  
  27. cout << "Hey, this is a retry function!";
  28.  
  29. cin >> buffer;
  30.  
  31. buffer[1]='\0'; //this removes the newline. This marks the end of the string. Not technically necessary as we only compare the first element, but for future comparisons.
  32.  
  33. if(buffer[0]=='y'){
  34.  
  35. mainfunc();
  36. return 1;
  37.  
  38.  
  39. }
  40. else{
  41. return 0;
  42.  
  43. }
  44.  
  45.  
  46.  
  47. }
  48.  
  49. int main(){
  50.  
  51. mainfunc();
  52.  
  53. while(retry()==1){};
  54.  
  55. system("pause");
  56.  
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement