I am learning Obj C and I tried my own version of the 'OR' operator from the book I am learning from. I simply am having the NSLog display text if the person presses a key that is 'a' through 'n'. If they don't the 'while' loop returns them to the question. Everything works but if they press a key that is out of the range it runs the loop twice again before I can use the 'scanf' again to enter a new character. It's like the Loop is stuck in a loop. Here is the code.
Any help would be great!
Code:
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
char crit;
int testNum = 0;
while ( testNum == 0)
{
NSLog(@"What was the Crit:");
scanf("%c", &crit);
if ( crit < 'a' || crit > 'm')
NSLog(@"That is not a correct responce");
else
testNum++;
}
NSLog(@"You selected %c", crit);
[pool drain];
return 0;
}
Any help would be great!