aboutsummaryrefslogtreecommitdiff
path: root/1.18.c
blob: 36f5ad9f34b1b8b42c43536c1da4bfba345f8c06 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <stdio.h>

#define MAXLINE 1000

int 
main(void)
{
  int input, i, non_blank;
  char str[MAXLINE];

  i = 0;
  non_blank = -1;

  while ((input = getchar()) != EOF) {
    while (input != '\n' && input != EOF) {
      str[i] = input;

      if (input != ' ' && input != '\t')
        non_blank = i;

      ++i;
      input = getchar();
    }

    if (non_blank == -1)
      continue;

    str[non_blank+1] = '\0';
    printf("%s\n", str);
    
    i = 0;
  }

  return 0;
}