commit 971e32a781ab7af4b1ae9bf112325ff4bff02801
parent e4c35b7d88735469333261c7a6329f3f57a54ef5
Author: qorg11 <qorg@vxempire.xyz>
Date: Tue, 16 Jun 2020 18:52:17 +0200
bare bones version of wc
Diffstat:
1 file changed, 20 insertions(+), 0 deletions(-)
diff --git a/src/wc.c b/src/wc.c
@@ -0,0 +1,20 @@
+#include <stdio.h>
+
+int
+main(void)
+{
+ char c;
+ int newlines = 0, spaces = 0, bytes = 0;
+
+ while((c = getchar()) != EOF)
+ {
+ bytes++;
+ if(c == '\n')
+ newlines++;
+ if(c == ' ')
+ spaces++;
+ }
+
+ printf("%i %i %i\n",newlines,spaces,bytes);
+ return 0;
+}