int main(void) {
char z;
while ( (z = getc(stdin)) != EOF) {
printf("%c", z);
}
int d, flag = 0;
char c;
while ((flag = fscanf(stdin, "%d", &d)) != EOF) {
if (flag == 1) {
printf("%d", d);
} else {
c = getc(stdin);
printf("%c", c);
}
}
return 0;
}
Hi, i have two variations here, there first one is char z which gets the character from input stream and prints it out. it returns exactly what i typed.
The second variation prints out exactly what i type except for the operators '+' and '-'. Kindly enlighten me here. I am confused as multiplication and division works in this variation and not + and -. Below is a screenshot: