#include <stdio.h>
main(void) {
char ch;
while (1) {
if ((ch = getchar()) != EOF)
{
break;
}
putchar(ch);
}
return 0;
}
How do I escape from this while
? I had tried with EOF but it didn't work.
I think you mean:
int ch;
Because EOF
won't fit in a char
.
Also:
if ((ch=getchar()) == EOF)
break;
Your logic is backwards.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With