Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <windows.h>
- using namespace std;
- void mainfunc(){
- int something=1;
- int somethingelse=2;
- int arandomvalue=something+somethingelse;
- cout << arandomvalue;
- }
- int retry(){
- //string Typedinletter;
- char buffer[2];
- //the second element is to hold the newline that the console should put on
- cout << "Hey, this is a retry function!";
- cin >> buffer;
- 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.
- if(buffer[0]=='y'){
- mainfunc();
- return 1;
- }
- else{
- return 0;
- }
- }
- int main(){
- mainfunc();
- while(retry()==1){};
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement