commit 7108aef1b31576bbeed414ca64a2ef6ad49e509c
parent b5402d89595bf01facc451205b80239bd7dc4304
Author: NunoSempere <nuno.sempere@protonmail.com>
Date: Fri, 8 Sep 2023 22:42:06 +0200
add function that simply echoes back from stdinput
Diffstat:
| A | makefile | | | 30 | ++++++++++++++++++++++++++++++ |
| A | wc | | | 0 | |
| A | wc.c | | | 10 | ++++++++++ |
3 files changed, 40 insertions(+), 0 deletions(-)
diff --git a/makefile b/makefile
@@ -0,0 +1,30 @@
+# Interface:
+# make
+# make build
+# make format
+
+# Compiler
+CC=gcc
+# CC=tcc # <= faster compilation
+
+# Main file
+SRC=wc.c
+OUTPUT=wc
+
+## Flags
+DEBUG= #'-g'
+STANDARD=-std=c99
+WARNINGS=-Wall
+OPTIMIZED=-O0
+# OPTIMIZED=-O3 #-Ofast
+
+## Formatter
+STYLE_BLUEPRINT=webkit
+FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT)
+
+## make build
+build: $(SRC)
+ $(CC) $(OPTIMIZED) $(DEBUG) $(SRC) -o $(OUTPUT)
+
+format: $(SRC)
+ $(FORMATTER) $(SRC)
diff --git a/wc b/wc
Binary files differ.
diff --git a/wc.c b/wc.c
@@ -0,0 +1,10 @@
+#include <unistd.h>
+#include <stdio.h>
+
+int main(){
+ char buffer[1];
+ while(read(0,buffer,sizeof(buffer)) > 0){
+ printf("%c", buffer[0]);
+ }
+ return 0;
+}