Yes or No Options
Alex via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Jul 27 09:24:21 PDT 2015
Thank you! That helped me a lot.
I'm sure that - in order to get to the point to repeat the whole
first part of the program - I'll have to read further in the
instructions I have BUT let's just say that I don't want it to
repeat the first part of the program but just writeln something
like "Ok let's do it again!" if I enter Y and press enter.
I now got to the point where the program doesn't quit but if I
enter "Y" and hit Enter, nothing happens.
I do understand how to define an int and then compare it to a
number I entered and do something if the number was
smaller/bigger/the same etc.
But how do I get the programm to simply write a line if I enter a
letter like Y?
With the code I got here it does not work. What is wrong with
this part here:
writeln("Do you want to play again? Y/N?");
readf(" %s", &yesno);
readln();
if (yesno == "Y") {
writeln("Yeah!");
}
Doesn't the code mean: Write "Do you want to play again? Y/N?".
Read keyboard input and define "yesno" by what was entered. And
then: If what was entered was a "Y", write the following line
"Yeah!".
Where is my error in thinking?
Sorry guys, I know it's probably something very easy..
More information about the Digitalmars-d-learn
mailing list