From: Steven Baltakatei Sandoval Date: Fri, 14 Jul 2023 04:57:50 +0000 (+0000) Subject: feat(src/kr/ch1/s1.1/e):Complete exercises X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2023-05.git/commitdiff_plain/87dabeece02a4b6cd12a9f42b3058596209a897c?ds=sidebyside feat(src/kr/ch1/s1.1/e):Complete exercises - chore(src/kr/ch1/s1.1):Add s1.1 practice code --- diff --git a/ref/src/YYYY-mm-dd..example/Makefile b/ref/src/YYYY-mm-dd..example/Makefile index 2a06090..b8e9d50 100644 --- a/ref/src/YYYY-mm-dd..example/Makefile +++ b/ref/src/YYYY-mm-dd..example/Makefile @@ -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 index 0000000..f47cb20 --- /dev/null +++ b/src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/.gitignore @@ -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 index 0000000..5429872 --- /dev/null +++ b/src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/Makefile @@ -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 index 0000000..01461d3 --- /dev/null +++ b/src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/control.c @@ -0,0 +1,6 @@ +#include + +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 index 0000000..f0ec890 --- /dev/null +++ b/src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/test1.c @@ -0,0 +1,6 @@ +#include + +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 index 0000000..16863a3 --- /dev/null +++ b/src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/test2.c @@ -0,0 +1,6 @@ +// #include + +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 index 0000000..7e331fb --- /dev/null +++ b/src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/test2.out.errmsg @@ -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 ‘’ or provide a declaration of ‘printf’ + +++ |+#include + 1 | // #include +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 ‘’ 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 index 0000000..caab3d1 --- /dev/null +++ b/src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/test3.c @@ -0,0 +1,6 @@ +#include + +// 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 index 0000000..cb3a4db --- /dev/null +++ b/src/kr_exercises/ch1/s1.1/e1.1..printf_experiments/test3.out.errmsg @@ -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 index 0000000..ce01362 --- /dev/null +++ b/src/kr_exercises/ch1/s1.1/e1.2..printf_experiments/.gitignore @@ -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 index 0000000..b8e9d50 --- /dev/null +++ b/src/kr_exercises/ch1/s1.1/e1.2..printf_experiments/Makefile @@ -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 index 0000000..53feca3 --- /dev/null +++ b/src/kr_exercises/ch1/s1.1/e1.2..printf_experiments/hello.c @@ -0,0 +1,11 @@ +#include +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 +} diff --git a/src/kr_exercises/ch1/s1.1/p6_hello_world/Makefile b/src/kr_exercises/ch1/s1.1/p6_hello_world/Makefile index 7a479ef..7787865 100644 --- a/src/kr_exercises/ch1/s1.1/p6_hello_world/Makefile +++ b/src/kr_exercises/ch1/s1.1/p6_hello_world/Makefile @@ -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 index 0000000..73304f7 --- /dev/null +++ b/src/kr_exercises/ch1/s1.1/p8_hello_world/.gitignore @@ -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 index 0000000..7787865 --- /dev/null +++ b/src/kr_exercises/ch1/s1.1/p8_hello_world/Makefile @@ -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 index 0000000..f8fa224 --- /dev/null +++ b/src/kr_exercises/ch1/s1.1/p8_hello_world/hello.c @@ -0,0 +1,7 @@ +#include + +main() { + printf("hello, "); + printf("world"); + printf("\n"); +}