diff --git a/lisp b/lisp deleted file mode 100755 index 37a4ec9..0000000 Binary files a/lisp and /dev/null differ diff --git a/makefile b/makefile index 0b24ede..653d8cf 100644 --- a/makefile +++ b/makefile @@ -8,15 +8,18 @@ ## C compiler CC=tcc # much faster compilation than gcc +## Debugging options +DEBUG=-g#-g + ## Main file -SRC=./src/lisp.c +SRC=./src/mumble.c ## Formatter STYLE_BLUEPRINT=webkit FORMATTER=clang-format -i -style=$(STYLE_BLUEPRINT) build: $(SRC) - $(CC) $(SRC) -o lisp + $(CC) $(SRC) -o mumble $(DEBUG) format: $(SRC) $(FORMATTER) $(SRC) diff --git a/notes/gbd-tutorial.txt b/notes/gbd-tutorial.txt new file mode 100644 index 0000000..d08b133 --- /dev/null +++ b/notes/gbd-tutorial.txt @@ -0,0 +1,130 @@ +From: + +In this article, let us discuss how to debug a c program using gdb debugger in 6 simple steps. + +### Write a sample C program with errors for debugging purpose + +To learn C program debugging, let us create the following C program that calculates and prints the factorial of a number. However this C program contains some errors in it for our debugging purpose. + +$ vim factorial.c +# include + +int main() +{ + int i, num, j; + printf ("Enter the number: "); + scanf ("%d", &num ); + + for (i=1; i - -int main(int argc, char** argv){ - puts("Hello world!"); - return 0; -} diff --git a/src/mumble.c b/src/mumble.c new file mode 100644 index 0000000..c162f6e --- /dev/null +++ b/src/mumble.c @@ -0,0 +1,20 @@ +#include + +static char input[2048]; + +int main(int argc, char** argv) +{ + puts("Mumble version 0.0.1\n"); + puts("Press Ctrl+C to exit\n"); + int loop = 1; + while (loop) { + fputs("mumble>", stdout); + void* catcher = fgets(input, 2048, stdin); + if (catcher == NULL) { + loop = 0; + } else { + printf("You said: %s", input); + } + } + return 0; +}