A program that prints its input one word per line.
int main() {
int c;
while ((c=getchar()) != EOF) {
if (c== ' ' || c== '\n' ||c == '\t')
putchar('\n');
else {
putchar(c);
}
}
return 0;
}
The above program prints the result correctly, one word per line. After changing the condition accordingly, I was expecting the program below to also print one word per line. However I am not getting the correct result. Am I making some silly mistake or is something wrong?
int main() {
int c;
while ((c=getchar()) != EOF) {
if (c != ' ' || c != '\n' || c != '\t')
putchar(c);
else {
putchar('\n');
}
}
return 0;
}