#include <stdio.h>
// source tutorial points
int main(){
int c;
char d;
printf("Enter First value \n");
c = getchar();
printf("Enter Second value \n");
d = getchar();
printf("You have entered first \n");
putchar(c);
printf("You have entered second \n");
putchar(d);
return(0);
}
当我输入第一个值时,它并没有要求其他值,请帮助我不要在char中输入一个不可能的字符。
Because each time you input a character and hit ENTER. So, second
getchar
in your code reads theenter
character.您的代码应更改为:
输出: