Explorar o código

Got myecho working, probably will want to do some error handling/cleanup though.

Lily Carpenter %!s(int64=12) %!d(string=hai) anos
pai
achega
f1bff06cc2
Modificáronse 2 ficheiros con 16 adicións e 0 borrados
  1. BIN=BIN
      myecho
  2. 16 0
      myecho.c

BIN=BIN
myecho


+ 16 - 0
myecho.c

@@ -0,0 +1,16 @@
1
+#include <stdio.h>
2
+#include <stdlib.h>
3
+#include <fcntl.h>
4
+const int size = 50; // chose this number for no particular reason
5
+
6
+int main() {
7
+    unsigned int number = 0;
8
+    unsigned int array[size];
9
+    int total;
10
+
11
+    while ((total = fread(array, sizeof number, size, stdin))){
12
+        for (int i = 0; i < total; i++){
13
+            printf("%i\n", array[i]);
14
+        }
15
+    }
16
+}