In anyone's opinion, what would be the best way to stop the program saying to the user "Press enter to continue"?
In anyone's opinion, what would be the best way to stop the program saying to the user "Press enter to continue"?
"Our greatest glory consists not in never failing,
but in rising every time we fall."
Oliver Goldsmith (1730-1774).
Anglo-Irish writer, poet and playwright.
One solution is the function ignore().
KuphrynCode:cout << "\nPress Enter to continue.\n"; cin.ignore(256, '\n');
what I mean is this
Now, str takes any letter but not enter. I would like to know how to have the user use enter to make the program continue.Code:cout << "Press enter to roll"; cin >> str;
"Our greatest glory consists not in never failing,
but in rising every time we fall."
Oliver Goldsmith (1730-1774).
Anglo-Irish writer, poet and playwright.
Thanks for the reply. But cin.ignore(256, '\n'); does not work. The program just keeps going.
"Our greatest glory consists not in never failing,
but in rising every time we fall."
Oliver Goldsmith (1730-1774).
Anglo-Irish writer, poet and playwright.
Well u could use virtual keys (<windows.h>) and do this:Now, str takes any letter but not enter. I would like to know how to have the user use enter to make the program continue.
do
{
....
....
.....
....
}
while (str != VK_ENTER)
This is just real quick its not rlly accurate but u get the idea.
Code:int main(void) { cout << "\nPress Enter to continue.\n"; while (cin.get() != '\n'); }
When all else fails, read the instructions.
If you're posting code, use code tags: [code] /* insert code here */ [/code]
Just wanted to thank everyone that took to time to read and answer the post. Your answers are always helpful and they always teach me different solutions to my problem. It's a great help!