commit 3c0d6a08cc806ab65dccb8a17fcb41dac6ec1f6e Author: tmeissner Date: Thu May 2 13:15:37 2019 +0200 Initial commit diff --git a/chapter_02/Makefile b/chapter_02/Makefile new file mode 100644 index 0000000..7d7f6e5 --- /dev/null +++ b/chapter_02/Makefile @@ -0,0 +1,10 @@ +all: hello_world + + +%: %.c + cc -std=c11 -Wall $@.c -o $@ + + +.PHONY: clean +clean: + rm -rf hello_world diff --git a/chapter_02/hello_world.c b/chapter_02/hello_world.c new file mode 100644 index 0000000..5ce9ce2 --- /dev/null +++ b/chapter_02/hello_world.c @@ -0,0 +1,7 @@ +#include + + +int main(int argc, char** argv) { + puts("Hello, world!"); + return 0; +} \ No newline at end of file diff --git a/chapter_04/Makefile b/chapter_04/Makefile new file mode 100644 index 0000000..fd95b78 --- /dev/null +++ b/chapter_04/Makefile @@ -0,0 +1,10 @@ +all: prompt + + +%: %.c + cc -std=c11 -Wall $@.c -o $@ + + +.PHONY: clean +clean: + rm -rf prompt diff --git a/chapter_04/prompt.c b/chapter_04/prompt.c new file mode 100644 index 0000000..10c8048 --- /dev/null +++ b/chapter_04/prompt.c @@ -0,0 +1,27 @@ +#include + + +/* Declare a buffer for user input of size 2048 */ +static char input[2048]; + + +int main(int argc, char const *argv[]) +{ + /* Print version and exit information */ + puts("Lispy version 0.0.0.0.1"); + puts("Press Ctrl+c to exit\n"); + + /* In a never ending loop */ + while (1) { + /* Output our prompt */ + fputs("lispy> ", stdout); + + /* Read a line of user input of max size 2014 */ + fgets(input, 2048, stdin); + + /* Echo input back to user */ + printf("No you're a %s", input); + } + + return 0; +}