This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

scanf causes putchar to be called

I have implemented my own putchar and _getkey functions to use a RS-232 connection to a PC.

All is working fine except for somthing very strange...

With code like:
char Buff[64];
printf("Enter some text\n");
scanf("%s", Buff);
printf("%s\n", Buff);

This is the output on the PC console
Enter some text
hello <- PC input
hello -> where did this come from?
hello -> expected output from printf

You can even remove the second printf call and it will still echo the input.

When I saw this I checked to see how many times putchar was called, and I
found that putchar is called sometime during the scanf call.

Why is this? The C51 scanf implentation shouldn't output correct?

Thanks for your help!