Browse Source

Initial commit

T. Meissner 6 months ago
commit
3c0d6a08cc
4 changed files with 54 additions and 0 deletions
  1. 10
    0
      chapter_02/Makefile
  2. 7
    0
      chapter_02/hello_world.c
  3. 10
    0
      chapter_04/Makefile
  4. 27
    0
      chapter_04/prompt.c

+ 10
- 0
chapter_02/Makefile View File

@@ -0,0 +1,10 @@
1
+all: hello_world
2
+
3
+
4
+%: %.c
5
+	cc -std=c11 -Wall $@.c -o $@
6
+
7
+
8
+.PHONY: clean
9
+clean:
10
+	rm -rf hello_world

+ 7
- 0
chapter_02/hello_world.c View File

@@ -0,0 +1,7 @@
1
+#include <stdio.h>
2
+
3
+
4
+int main(int argc, char** argv) {
5
+    puts("Hello, world!");
6
+    return 0;
7
+}

+ 10
- 0
chapter_04/Makefile View File

@@ -0,0 +1,10 @@
1
+all: prompt
2
+
3
+
4
+%: %.c
5
+	cc -std=c11 -Wall $@.c -o $@
6
+
7
+
8
+.PHONY: clean
9
+clean:
10
+	rm -rf prompt

+ 27
- 0
chapter_04/prompt.c View File

@@ -0,0 +1,27 @@
1
+#include <stdio.h>
2
+
3
+
4
+/* Declare a buffer for user input of size 2048 */
5
+static char input[2048];
6
+
7
+
8
+int main(int argc, char const *argv[])
9
+{
10
+    /* Print version and exit information */
11
+    puts("Lispy version 0.0.0.0.1");
12
+    puts("Press Ctrl+c to exit\n");
13
+
14
+    /* In a never ending loop */
15
+    while (1) {
16
+        /* Output our prompt */
17
+        fputs("lispy> ", stdout);
18
+
19
+        /* Read a line of user input of max size 2014 */
20
+        fgets(input, 2048, stdin);
21
+
22
+        /* Echo input back to user */
23
+        printf("No you're a %s", input);
24
+    }
25
+
26
+    return 0;
27
+}