From: Steven Baltakatei Sandoval Date: Mon, 10 Jul 2023 09:25:25 +0000 (+0000) Subject: feat(src:2023-07-10):Add hello world, make test X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2023-05.git/commitdiff_plain/be2cbdd7067e8f5b8de827f3aded571eac5838c3 feat(src:2023-07-10):Add hello world, make test - chore(README):Update --- diff --git a/README.org b/README.org index 576ea41..a79bb3b 100644 --- a/README.org +++ b/README.org @@ -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 index 0000000..ce01362 --- /dev/null +++ b/src/2023-07-10..hello_world/.gitignore @@ -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 index 0000000..2a06090 --- /dev/null +++ b/src/2023-07-10..hello_world/Makefile @@ -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 index 0000000..7791fbb --- /dev/null +++ b/src/2023-07-10..hello_world/hello.c @@ -0,0 +1,6 @@ +#include + +int main() { + printf("Hello world!\n"); + return 0; +}