]> zdv2.bktei.com Git - BK-2023-05.git/commitdiff
feat(src/kr/ch1/s1.1/e):Complete exercises
authorSteven Baltakatei Sandoval <baltakatei@gmail.com>
Fri, 14 Jul 2023 04:57:50 +0000 (04:57 +0000)
committerSteven Baltakatei Sandoval <baltakatei@gmail.com>
Fri, 14 Jul 2023 04:57:50 +0000 (04:57 +0000)
- chore(src/kr/ch1/s1.1):Add s1.1 practice code

16 files changed:
ref/src/YYYY-mm-dd..example/Makefile
src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/.gitignore [new file with mode: 0644]
src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/Makefile [new file with mode: 0644]
src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/control.c [new file with mode: 0644]
src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/test1.c [new file with mode: 0644]
src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/test2.c [new file with mode: 0644]
src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/test2.out.errmsg [new file with mode: 0644]
src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/test3.c [new file with mode: 0644]
src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/test3.out.errmsg [new file with mode: 0644]
src/kr_exercises/ch1/s1.1/e1.2..printf_experiments/.gitignore [new file with mode: 0644]
src/kr_exercises/ch1/s1.1/e1.2..printf_experiments/Makefile [new file with mode: 0644]
src/kr_exercises/ch1/s1.1/e1.2..printf_experiments/hello.c [new file with mode: 0644]
src/kr_exercises/ch1/s1.1/p6_hello_world/Makefile
src/kr_exercises/ch1/s1.1/p8_hello_world/.gitignore [new file with mode: 0644]
src/kr_exercises/ch1/s1.1/p8_hello_world/Makefile [new file with mode: 0644]
src/kr_exercises/ch1/s1.1/p8_hello_world/hello.c [new file with mode: 0644]

index 2a06090d927cb1639caca933d17902d77bd72090..b8e9d50c786b434e24347c576c8dba635d005049 100644 (file)
@@ -1,5 +1,5 @@
 CC=gcc
-CFLAGS=-Wall -Wextra -pedantic
+CFLAGS=-x c -Wall -Wextra -pedantic
 OUTFILE=hello
 SOURCE=hello.c
 
diff --git a/src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/.gitignore b/src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/.gitignore
new file mode 100644 (file)
index 0000000..f47cb20
--- /dev/null
@@ -0,0 +1 @@
+*.out
diff --git a/src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/Makefile b/src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/Makefile
new file mode 100644 (file)
index 0000000..5429872
--- /dev/null
@@ -0,0 +1,19 @@
+CC=gcc
+CFLAGS=-x c -Wall -Wextra -pedantic
+
+all: control test1 test2 test3
+
+control: control.c
+       $(CC) $(CFLAGS) -o control.out control.c
+
+test1: test1.c
+       $(CC) $(CFLAGS) -o test1.out test1.c
+
+test2: test2.c
+       $(CC) $(CFLAGS) -o test2.out test2.c
+
+test3: test3.c
+       $(CC) $(CFLAGS) -o test3.out test3.c
+
+clean:
+       rm ./*.out
diff --git a/src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/control.c b/src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/control.c
new file mode 100644 (file)
index 0000000..01461d3
--- /dev/null
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main()
+{
+  printf("Hello, world.\n");
+}
diff --git a/src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/test1.c b/src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/test1.c
new file mode 100644 (file)
index 0000000..f0ec890
--- /dev/null
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main()
+{
+  //  printf("Hello, world.\n");
+}
diff --git a/src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/test2.c b/src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/test2.c
new file mode 100644 (file)
index 0000000..16863a3
--- /dev/null
@@ -0,0 +1,6 @@
+// #include <stdio.h>
+
+int main()
+{
+  printf("Hello, world.\n");
+}
diff --git a/src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/test2.out.errmsg b/src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/test2.out.errmsg
new file mode 100644 (file)
index 0000000..7e331fb
--- /dev/null
@@ -0,0 +1,12 @@
+$ gcc -x c -Wall -Wextra -pedantic -o test2.out test2.c
+test2.c: In function ‘main’:
+test2.c:5:3: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
+    5 |   printf("Hello, world.\n");
+      |   ^~~~~~
+test2.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
+  +++ |+#include <stdio.h>
+    1 | // #include <stdio.h>
+test2.c:5:3: warning: incompatible implicit declaration of built-in function ‘printf’ [-Wbuiltin-declaration-mismatch]
+    5 |   printf("Hello, world.\n");
+      |   ^~~~~~
+test2.c:5:3: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
diff --git a/src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/test3.c b/src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/test3.c
new file mode 100644 (file)
index 0000000..caab3d1
--- /dev/null
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+// int main()
+{
+  printf("Hello, world.\n");
+}
diff --git a/src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/test3.out.errmsg b/src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/test3.out.errmsg
new file mode 100644 (file)
index 0000000..cb3a4db
--- /dev/null
@@ -0,0 +1,5 @@
+gcc -x c -Wall -Wextra -pedantic -o test3.out test3.c
+test3.c:4:1: error: expected identifier or ‘(’ before ‘{’ token
+    4 | {
+      | ^
+make: *** [Makefile:16: test3] Error 1
diff --git a/src/kr_exercises/ch1/s1.1/e1.2..printf_experiments/.gitignore b/src/kr_exercises/ch1/s1.1/e1.2..printf_experiments/.gitignore
new file mode 100644 (file)
index 0000000..ce01362
--- /dev/null
@@ -0,0 +1 @@
+hello
diff --git a/src/kr_exercises/ch1/s1.1/e1.2..printf_experiments/Makefile b/src/kr_exercises/ch1/s1.1/e1.2..printf_experiments/Makefile
new file mode 100644 (file)
index 0000000..b8e9d50
--- /dev/null
@@ -0,0 +1,10 @@
+CC=gcc
+CFLAGS=-x c -Wall -Wextra -pedantic
+OUTFILE=hello
+SOURCE=hello.c
+
+all: $(SOURCE)
+       $(CC) $(CFLAGS) -o $(OUTFILE) $(SOURCE)
+
+clean:
+       rm -f $(OUTFILE)
diff --git a/src/kr_exercises/ch1/s1.1/e1.2..printf_experiments/hello.c b/src/kr_exercises/ch1/s1.1/e1.2..printf_experiments/hello.c
new file mode 100644 (file)
index 0000000..53feca3
--- /dev/null
@@ -0,0 +1,11 @@
+#include <stdio.h>
+int main()
+{
+  printf("hello\n");  
+  printf("\v");        // Vertical tab
+  printf("world\?\n"); // Question mark
+  printf("foo\x0A");   // Newline (hexadecimal)
+  printf("ba\br\n");   // Backspace
+  printf("baz\b\n");   // Backspace moves cursor back but doesn't overwrite z
+  printf("baz\b \n");  // Backspace overwrites z with space
+}
index 7a479efbda77ef7cf76e861595183a5fa2234159..778786509f9226cba8ffff37c2ca17bb598299d7 100644 (file)
@@ -1,5 +1,5 @@
 CC=gcc
-CFLAGS=-Wall -Wextra -pedantic
+CFLAGS=-x c -Wall -Wextra -pedantic
 OUTFILE=a.out
 SOURCE=hello.c
 
diff --git a/src/kr_exercises/ch1/s1.1/p8_hello_world/.gitignore b/src/kr_exercises/ch1/s1.1/p8_hello_world/.gitignore
new file mode 100644 (file)
index 0000000..73304f7
--- /dev/null
@@ -0,0 +1,2 @@
+hello
+a.out
diff --git a/src/kr_exercises/ch1/s1.1/p8_hello_world/Makefile b/src/kr_exercises/ch1/s1.1/p8_hello_world/Makefile
new file mode 100644 (file)
index 0000000..7787865
--- /dev/null
@@ -0,0 +1,10 @@
+CC=gcc
+CFLAGS=-x c -Wall -Wextra -pedantic
+OUTFILE=a.out
+SOURCE=hello.c
+
+all: $(SOURCE)
+       $(CC) $(CFLAGS) -o $(OUTFILE) $(SOURCE)
+
+clean:
+       rm -f $(OUTFILE)
diff --git a/src/kr_exercises/ch1/s1.1/p8_hello_world/hello.c b/src/kr_exercises/ch1/s1.1/p8_hello_world/hello.c
new file mode 100644 (file)
index 0000000..f8fa224
--- /dev/null
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+main() {
+  printf("hello, ");
+  printf("world");
+  printf("\n");
+}