basically i thought of do while loop but i don't know if it's possible in my case
because im making a program with many end (end being game over im making an interactive fiction program where there is a lot of dead ends)
and i would like to put an option in those ends that says something like "play again? [y/n]"
cout<<"blhablahblahblah"; //some story or whatever
cout<<"choose A or B or C?";
cin>>choice1; ///this is where the player chooses his path or choice idk.
if (choice1=='A')
{
cout<<"blahblahblah"; ///more of the story the branches out to many paths until a dead end or just finishing the game
///more codes here
cout<<"A. Go further \nB. Go back \n.C. Stay still"; ///now here's the problem for example, choice B & C is a dead end
cin>>choice25;
if (choice25=='A')
{
cout<<"blahblahmore storyline"; ///more story and dead ends
}
elseif (choice25=='B')
{
cout<<"blahblahblahh";
cout<<"Game over"; ///here's where i want the 'restart the game or not' option
}
elseif (choice25=='C')
{
cout<<"asdsadasdhaksjhdsa"; ///also a dead end but they have different outcome so i separated choice B & C
cout<<"Game over";
}
because i want some sort of fool proof input like when a user inputs an 'a' instead of 'A'
idk if that works in switch xD (we just finished discussing about loops and this is my project for this week)
i just finished coding 2500+ lines last night before someone told me about toupper and all other things and im like f* it xD
right now i just want a little polishing like as i mention above
bool play_once_again()
{
std::cout << "play once again (y/n)? " ;
char again ;
return std::cin >> again && ( again == 'y' || again == 'Y' ) ;
}
int main()
{
do
{
// play the game once
// if( the game has ended )
continue ; // http://en.cppreference.com/w/cpp/language/continue
// ...
// if( the game has ended here )
continue ;
// ...
}
while( play_once_again() ) ;
}
Anyway they all do the same thing if you incorporate a while loop.
I'm guessing but I get the distinct impression you need to get the logic and flow straightened out which is best done with a pencil and paper diagram/flowchart.