I wrote a program to read from input character by character and print it to output and here is my code:
#include <stdio.h>
main()
{
int c;
while((c = getchar()) != EOF)
{
printf("%s\n", "log1");
printf("%c\n", c);
printf("%s\n", "log2");
}
}
and this is the result:
a(my input)
log1
a
log2
log1
log2
but it should have this result:
a
log1
a
log2
what's wrong with this program?