So my problem is this I want to print numbers that come from the terminal while the numbers are different than the EOF.
For example if put 007 as the input, I want the output to be 7 or if I put 42 I want the output to be 42.
But for some reason, the output I get is a random number, that I cant understand.
program:
#include <stdio.h>
void ex04();
int main() {
ex04();
return 0;
}
void ex04() {
int c;
c = getchar();
while (c != EOF) {
printf("%d\n",c);
c = getchar();
}
}
Input: 007
my Output:
48
48
55
10
Correct Output: 7
Any help would be appreciated.