diff options
Diffstat (limited to '2/2.c')
| -rw-r--r-- | 2/2.c | 25 |
1 files changed, 25 insertions, 0 deletions
@@ -0,0 +1,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; +}
\ No newline at end of file |
