循环到第二次时scanf函数会自动获取\n,这个是为什么?

#include;
//#include
//#define PI 3.1415926
int main(void)
{
char letter=0;
while(1)
{
printf("Enter an upcase letter:");
scanf("%c",&letter);
if(letter>='A')
if(letter<='Z')
{
letter=letter-'A'+'a';
printf("You entered an uppercase %c\n",letter);
}
else
printf("Try using the shift key,Bud!I want a capital letter.\n");
else
printf("You didn't enter an uppercase letter.\n");

};
return 0;

};

看 MSDN 的示例,应该不存在所描述的问题。难道是回车多按了一次?

 /* SCANF.C: This program uses the scanf and wscanf functions
  * to read formatted input.
  */

#include <stdio.h>

void main( void )
{
   int   i, result;
   float fp;
   char  c, s[81];
   wchar_t wc, ws[81];

   printf( "\n\nEnter an int, a float, two chars and two strings\n");

   result = scanf( "%d %f %c %C %s %S", &i, &fp, &c, &wc, s, ws );
   printf( "\nThe number of fields input is %d\n", result );
   printf( "The contents are: %d %f %c %C %s %S\n", i, fp, c, wc, s, ws);

   wprintf( L"\n\nEnter an int, a float, two chars and two strings\n");

   result = wscanf( L"%d %f %hc %lc %S %ls", &i, &fp, &c, &wc, s, ws );
   wprintf( L"\nThe number of fields input is %d\n", result );
   wprintf( L"The contents are: %d %f %C %c %hs %s\n", i, fp, c, wc, s, ws);
}
Output
Enter an int, a float, two chars and two strings
71
98.6
h
z
Byte characters

The number of fields input is 6
The contents are: 71 98.599998 h z Byte characters

Enter an int, a float, two chars and two strings
36
92.3
y
n
Wide characters

The number of fields input is 6
The contents are: 456 92.300003 y n Wide characters

全部输入打印出来对比一下

好多人都会遇到这问题,因为scanf没读完所有缓存中的信息。把回车剩外面了,被下次的scanf接收到了。