cleaning the buffer
in my program i use a menu - to get the value for the menu i use getch();, after this i use cin<< to get data from the user, the only problem is the charcter left over form the getch is in the space to type data, i have tried lots of ways but cannot get rid of it - any ideas?
hmm memset() maybe?
whats memset, i though that was something to do with memory allocation? how do i use that?
After you use the value from getch, call cin.ignore(). That will clear the input stream buffer so that you can read another value.
If you KNOW there is only one char left in the buffer then use the syntax:
which uses the default partameters of 1 and newline char respectively. Otherwise, you can adjust at your discretion using the prototype:
cin.ignore(int numberOfCharToIgnore, char terminatingChar);