How to clear input buffer in C?

前端 未结 12 2351
一个人的身影
一个人的身影 2020-11-21 08:45

I have the following program:

int main(int argc, char *argv[])
{
  char ch1, ch2;
  printf(\"Input the first character:\"); // Line 1
  scanf(\"%c\", &ch         


        
12条回答
  •  甜味超标
    2020-11-21 09:15

    unsigned char a=0;
    if(kbhit()){
        a=getch();
        while(kbhit())
            getch();
    }
    cout<(a) & 0xFF)<

    -or-

    use maybe use _getch_nolock() ..???

提交回复
热议问题