Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Exercise 1-12. Write a program that prints its input one word per line.*/
- #include <stdio.h>
- int main()
- {
- int flag = 1, c;
- while ((c = getchar()) != EOF) {
- if (c == ' ' || c == '\t' || c == '\n') {
- if (flag == 0) {
- putchar('\n');
- flag = 1;
- }
- } else {
- putchar(c);
- flag = 0;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment