Been trying to figure out this for an hour with no luck. Learned other things along the way, but not an answer to this problem.
I've a simple program to use scanf ... enter a number, print a number.
Code:
#import <Foundation/Foundation.h>
int main (int argc, const char * argv[]) {
int a;
printf ("Enter a number: ");
scanf ("%d", &a);
printf ("Number is %d\n", a);
return 0;
}
When I run it, I type in a number and then press Enter. System just sits there, not moving on to the printf command. The only way I could get it to work was to type a number and then actually type in \n before pressing Enter (e.g. 456\n). Then the program would proceed.
But when I changed my input type to a char, things worked fine with a simple Enter after a char.
Please help me understand what I'm missing here. Thanks.
Jim