Writing a program...simple thing I can't seem to figure out. In a menu, if a user opts to exit program, the program should then prompt user "press ENTER to exit"...how can I do this? I am trying to make it that it must be ENTER.
Thanks in adv.
Writing a program...simple thing I can't seem to figure out. In a menu, if a user opts to exit program, the program should then prompt user "press ENTER to exit"...how can I do this? I am trying to make it that it must be ENTER.
Thanks in adv.
This cannot be done with standard library facilities as the user will be able to type in other input before pressing enter.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
Thanks for the info...however; after digging around even further...found this bit of code that worked perfectly:
Code:fflush(stdin); printf("\nPress ENTER to exit..."); while (getch() != 13) { printf("\nPress ENTER to exit...") }
Yeah. Note that ffush(stdin) results in undefined behaviour and getch is non-standard. You should also avoid magic numbers, e.g., use '\r' instead of 13.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
I really never understood why this features wasn't included within the standard library? This seems like tho such a useful feature and all non standard library provides them :/
Life is like riding a bicycle. To keep your balance you must keep moving - Einstein
Probably because it requires a notion of interactive input that is too specific for a general standard. Still, I suppose it could have been an optional part of the standard.Originally Posted by ssharish2005
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)