I wish to create a 'naming' application. You submit a name and are asked whether this is correct or not. If yes, the program proceeds, if not, I want the naming procedure to start again. I believe this is done by the use of subroutines, but I cannot for the life of me figure out how. Step by step instructions, or else a link to the correct keyword to use would be greatly appreciated.
Feel free to ask if something needs clearing up! Sorry for my foolishness.
Here is the current code:
#include <iostream>
#include "conio.h"
#include <string>
using namespace std;
void main(){
cout << "Welcome to Strontium!" << endl;
string nameAnswer;
string playerName;
cout << "What is your name? " << endl;
cout << "> ";
getline(cin, playerName);
cin.clear();
cout << "Your name is " << playerName;
cout << "? Yes/No." << endl;
cout << "> ";
cin >> nameAnswer;
if(nameAnswer == "yes"){
cout << "Very good. Thank you.";}
if(nameAnswer == "no"){ Here is where I wish the program to return to 'string nameAnswer;' and follow on from there. However, I don't know whether the code needs to be within a .h file, or a separate .cpp, or whether I can just use a keyword!
}
}
Flaming marvellous! Thank you so much! I've been tearing my hair out trying to do this. In regards to conio.h; I've bee following a set of tutorials and they advise to include it, so it's just become habit. *Shrug*. Thank you again!