Second scanf is not working

前端 未结 5 1673
旧巷少年郎
旧巷少年郎 2020-12-06 19:36

i am having trouble with this c language code:

 char st[2];

 printf(\"enter first value:\");
 scanf(\"%c\", &st[0]);

 printf(\"enter second value:\");
         


        
5条回答
  •  渐次进展
    2020-12-06 20:03

    Change

    scanf("%c", &st[0]);
    

    to this

    scanf(" %c", &st[0]);
    

    That's a shotty answer (no error checking or anything) but its quick and easy.

提交回复
热议问题