From dcdc22025931ef54713f959152a667fcd792cc13 Mon Sep 17 00:00:00 2001 From: Kris Lamoureux Date: Fri, 5 Nov 2021 20:54:19 -0400 Subject: [PATCH] Textbook example of copying input into output --- 04-file-copying.c | 13 +++++++++++++ Makefile | 5 ++++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 04-file-copying.c diff --git a/04-file-copying.c b/04-file-copying.c new file mode 100644 index 0000000..5c7e6f2 --- /dev/null +++ b/04-file-copying.c @@ -0,0 +1,13 @@ +#include + +/* copy input to output; 1st version */ +int main() +{ + int c; + + c = getchar(); + while (c != EOF) { + putchar(c); + c = getchar(); + } +} diff --git a/Makefile b/Makefile index 3fcaad8..e70c2c4 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -all: hello mathvars c2f +all: hello mathvars c2f input hello: 01-hello-world.c gcc -o ./bin/01-helloworld 01-hello-world.c @@ -9,5 +9,8 @@ mathvars: 02-vars-and-math.c c2f: 03-celsius-to-fahrenheit.c gcc -o ./bin/03-c2f 03-celsius-to-fahrenheit.c +input: 04-file-copying.c + gcc -o ./bin/04-input 04-file-copying.c + clean: $(RM) ./bin/*-*