I'm just learning C and was trying to run the following basic example below; problem is that it doesn't do what it is supposed to, instead of reading a character from the kb and display it, it reads an input string (until I pres <ENTER>) and then it displays it. What's wrong?
The following is quoted from the book I'm learning from:
----------------------------------------------------------------
getchar
The following program illustrates this,
#include <stdio.h>
main()
{
int i, ch;
for( i = 1; i <= 5; ++i ) {
ch = getchar();
putchar(ch);
}
}
Sample Program Output
AACCddEEtt
--------------------------------------------------------------