My particular question is:
How does the program clear the screen only when the user inputs '+' followed by Enter? I can see that the sentence if tells the program to scanf (whathever caracter may come next, and assign it to variable Espera) But, how does it manage to produce different results depending on the vrey following key?
Does the key ENTER (RETURN, INTRO) have a particular effect on the code sequence?
Thank you very much...
The way the system works is that when you press Enter, whatever you have typed is sent to the program. So if you type '+' then press Enter, the program reads just the '+' and runs the if-block, clearing the screen.
Thank you so much mukomo.
I found several other examples in the same page and all cleared the screen the same way.
I understand now that Enter is sort of a way of making the code go to the next line.
Thanks again for your quick answer.
Thank you Chervil, I did try what you suggested and now I have a better comprehension of what´s going on here. Very clever of you changing %c to [%c] in the while loop, to better track it. Nice trick, i´ll shurely use it again...
Yet my doubt is still another...
The last hour I´ve been trying to start a simple "guess my number" game with the usual "Press INTRO to continue" after explaining the rules...
How should I apply this method scanf("%c",&Espera);
to any situation?
I´m used to read users keyboard inputs whith cin >> variable;, and I can´t seem to find the way... But I guess that´s the question for a new topic.