summaryrefslogtreecommitdiffstats
path: root/2
diff options
context:
space:
mode:
Diffstat (limited to '2')
-rw-r--r--2/2.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/2/2.c b/2/2.c
new file mode 100644
index 0000000..f68d4b5
--- /dev/null
+++ b/2/2.c
@@ -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