i want to getchar twice but i cant

后端 未结 2 1398
梦谈多话
梦谈多话 2021-01-22 15:20
int main()
{
    int r, c;
    r = getchar();
    c = getchar();
    putchar(r);
    putchar(c);
    printf(\"\\n\");
    return(0);
}

After it reads i

2条回答
  •  北恋
    北恋 (楼主)
    2021-01-22 15:32

    You're probably typing X + Enter. The first getchar() reads the character X, and the second getchar() reads a newline generated when you press Enter. Type both your characters without pressing Enter.

提交回复
热议问题