在vs 6.0中,写了个CONSOLE类型的程序,为什么getchar()不会每次取一个输入的值,而要按回车后才能进行取值操作!但是这样又不对啊!

解决方案 »

  1.   

    你可以自己处理阿
    #include <stdio.h>void main( void )
    {
       char buffer[81];
       int i, ch;   printf( "Enter a line: " );   /* Read in single line from "stdin": */
       for( i = 0; (i < 80) &&  ((ch = getchar()) != EOF) 
                            && (ch != '\n'); i++ )
          buffer[i] = (char)ch;   /* Terminate string with null character: */
       buffer[i] = '\0';
       printf( "%s\n", buffer );
    }
    OutputEnter a line: This is a test
    This is a test
      

  2.   

    _getch, _getche
    Get a character from the console without echo (_getch) or with echo (_getche).
      

  3.   

    不是的,肯定是你写错了,getchar()读取每个字符,包括回车
      

  4.   

    getchar()每次是读入一个字符,但按回车后才执行的
      

  5.   

    while(_getch()!=27 )
    这个可以