It’s probably a simple correction since the program is super short but please help me understand why am i getting weird output:
#include <stdio.h>
int main(void)
{
char x;
printf("please enter a word, and ctrl + d to see the resault\n");
while ((x = getchar()) != EOF)
{
printf("%d", x);
}
return 0;
}
intput: 'd'
output: 10010
The reason you get 10010 is because you are pressing ‘d’ followed by ‘return’.
Change your printf format to “%d\n” to visualize this more easily.
A fix could be: