]> zdv2.bktei.com Git - BK-2023-05.git/commitdiff
feat(src:2023-07-10):Add hello world, make test
authorSteven Baltakatei Sandoval <baltakatei@gmail.com>
Mon, 10 Jul 2023 09:25:25 +0000 (09:25 +0000)
committerSteven Baltakatei Sandoval <baltakatei@gmail.com>
Mon, 10 Jul 2023 09:25:25 +0000 (09:25 +0000)
- chore(README):Update

README.org
src/2023-07-10..hello_world/.gitignore [new file with mode: 0644]
src/2023-07-10..hello_world/Makefile [new file with mode: 0644]
src/2023-07-10..hello_world/hello.c [new file with mode: 0644]

index 576ea411a4156174d53dd50f5161e10f7c325231..a79bb3b99f1815c9d379dce1795be35840962c7d 100644 (file)
@@ -1,9 +1,33 @@
 * Learning C
+#+TITLE: Learning C
+#+AUTHOR: Steven Baltakatei Sandoval
+#+DATE: 2023-07-10
+#+EMAIL: baltakatei@gmail.com
+
 ** Summary
 This repository contains practice code and examples as I learn how to
 program in C.
 
 ** Compiling Procedure
+*** Compiling with ~gcc~
 See [[https://www.linuxtopia.org/online_books/an_introduction_to_gcc/gccintro_9.html][ref]].
 
 : $ gcc -Wall -o hello.c hello
+
+*** Managing compiling with ~make~
+Create ~Makefile~ to specify compile options.
+
+#+begin_example
+CC=gcc
+CFLAGS=-Wall -Wextra -pedantic
+OUTFILE=hello
+SOURCE=hello.c
+
+all: $(SOURCE)
+  $(CC) $(CFLAGS) -o $(OUTFILE) $(SOURCE)
+
+clean:
+  rm -f $(OUTFILE)
+#+end_example
+
+Then, run the file named ~Makefile~ via ~make all~ or simply ~make~.
diff --git a/src/2023-07-10..hello_world/.gitignore b/src/2023-07-10..hello_world/.gitignore
new file mode 100644 (file)
index 0000000..ce01362
--- /dev/null
@@ -0,0 +1 @@
+hello
diff --git a/src/2023-07-10..hello_world/Makefile b/src/2023-07-10..hello_world/Makefile
new file mode 100644 (file)
index 0000000..2a06090
--- /dev/null
@@ -0,0 +1,10 @@
+CC=gcc
+CFLAGS=-Wall -Wextra -pedantic
+OUTFILE=hello
+SOURCE=hello.c
+
+all: $(SOURCE)
+       $(CC) $(CFLAGS) -o $(OUTFILE) $(SOURCE)
+
+clean:
+       rm -f $(OUTFILE)
diff --git a/src/2023-07-10..hello_world/hello.c b/src/2023-07-10..hello_world/hello.c
new file mode 100644 (file)
index 0000000..7791fbb
--- /dev/null
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main() {
+  printf("Hello world!\n");
+  return 0;
+}