add function that simply echoes back from stdinput

This commit is contained in:
NunoSempere 2023-09-08 22:42:06 +02:00
parent b5402d8959
commit 7108aef1b3
3 changed files with 40 additions and 0 deletions

30
makefile Normal file
View File

@ -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)

BIN
wc Executable file

Binary file not shown.

10
wc.c Normal file
View File

@ -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;
}