summaryrefslogtreecommitdiffstats
path: root/2/2.c
blob: f68d4b59bdee4e3305fdb95a5b1b0602fd64969b (plain)
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
#include <stdio.h>

#define MAXLEN 1000

/* writes input to buffer without using && or || in loop */
int main(int argc, char *argv[]) {
  int i, c;
  char s[MAXLEN];

  for (i = 0; i < MAXLEN - 1; i++) {
    if ((c = getchar()) == EOF) {
      break;
    }

    if (c == '\n') {
      break;
    }

    s[i] = c;
  }

  s[i] = 0;

  return 0;
}