Problems with scanf

前端 未结 4 1426
粉色の甜心
粉色の甜心 2020-12-20 09:05
#include 

int main()
{

    char C, B;
    int x;



    printf(\"What comes after G\\n\");
    scanf(\"%c\", &C);

    printf(\"What comes after         


        
4条回答
  •  抹茶落季
    2020-12-20 09:24

    The problem is you are using scanf to get the character ..and a new line will be added at the end of each input from user . So the second time only the new line will be stored in the 'B' Because of the first input given by you ..

    Instead of scanf , change it to getchar - your problem should get solved

提交回复
热议问题