Reputation: 4180
I am using the book 'The C Programming Language' to learn C.
I copied code exactly but the putchar()
won't return the value of what the user types in.
#include <stdio.h>
main()
{
int c;
c = getchar();
while (c != EOF) {
putchar(c);
c = getchar();
}
}
If I input this
c
I don't get any output
Upvotes: 0
Views: 802
Reputation: 1161
Try this:
int main()
{
int c;
while ((c = getchar()) != EOF) {
putchar(c);
fflush(stdout);
}
}
Upvotes: 3