Could someone help me out with this? I'm trying to make sure that the code I'm working on is standard. I'm using VC++6.
Here's the snippet in question(btw I'm still just a newb) :
It's just the controlling loop in main. The ... represents the rest of the function calls that do the work of the program. 'again' was previously defined as TRUE before the loop started.Code:while(again) { ... printf("Do it again Y/N?"); c=toupper(getch()); // need ansi alternative to getch here if(c=='N') { printf("N\n"); again=FALSE; } else // as long as it's not 'N' or 'n' we continue printf("Y\n"); }
What I'm concerned with is 'getch()' since it is not ansi. All I want is for the user to be able to hit 'N' or 'n' to quit and basicly any other key to continue, but I don't want them to have to hit [enter] after they choose. All I've been able to learn how to do this is either use getch() or kbhit(), neither of which I want.
I tried searching the boards the other day and google tonight but wasn't sure how to best refine the search. At google I mostly found descriptions of it's non-portability but no alternatives other than to use getchar.
Is this an age-old newbie question or am I just being obtuse and narrow minded?
Ragman