Skip to content

A clean solution to Exercise 1-12 #81

@ChenZhongPu

Description

@ChenZhongPu
#include <stdbool.h>
#include <stdio.h>

int main() {
  int c;
  bool in_word = false;

  while ((c = getchar()) != EOF) {
    if (c == ' ' || c == '\t' || c == '\n') {
      if (in_word) {
        putchar('\n');
      }
      in_word = false;
    } else {
      putchar(c);
      in_word = true;
    }
  }
  return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions