当前位置: 代码迷 >> C语言 >> 请大家帮我分析一下!
  详细解决方案

请大家帮我分析一下!

热度:265   发布时间:2008-03-14 16:00:19.0
请大家帮我分析一下!
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
int main(void)
{
    char ch;
    for(;;)
    {
        puts("按a)");
        puts("按b)");
        puts("按q)");
        printf("Input:");
        switch(tolower(ch=getchar()))
        {
          while(getchar()!='\n')
           continue;
          case 'a':
           printf("\nThis is %c\n",ch);
           break;
          case 'b':
           printf("\nThis is %c\n",ch);
           break;
          case 'q':
           exit(EXIT_FAILURE);
          default:
           printf("\nError.\n");
        }
    }
        
    return 0;
}

问题:为什么红色部while(getchar()!='\n') 这条两 语句没有吃掉'\n'!
                   continue;
搜索更多相关的解决方案: 分析  continue  include  

----------------解决方案--------------------------------------------------------
  相关解决方案