Why is it that the following code:
printf("? ");
scanf("%d", &n);
printf("? ");
gets(str);
skip the gets(str) step?
My guess is that the carriage return is not stored into n and still in the stdin, so that when gets(str) is called, the carriage return is encountered. Am I correct?
Is there anyway to solve this anomaly besides switching the positions of the code or use gets() and atoi?