commit a9cbe1c5c4da143837a8f13008542c35eee49502 Author: TropiiDev Date: Tue Apr 15 23:24:37 2025 -0400 Initial Commit v0.0.1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..256afe5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +main +cmake-build-debug/ +CMakeLists.txt diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/BasicCalc.iml b/.idea/BasicCalc.iml new file mode 100644 index 0000000..f08604b --- /dev/null +++ b/.idea/BasicCalc.iml @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/.idea/editor.xml b/.idea/editor.xml new file mode 100644 index 0000000..1f0ef49 --- /dev/null +++ b/.idea/editor.xml @@ -0,0 +1,580 @@ + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..0b76fe5 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..be7956d --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..83cbcb8 --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +main: main.c + gcc main.c -o main \ No newline at end of file diff --git a/main.c b/main.c new file mode 100644 index 0000000..357268c --- /dev/null +++ b/main.c @@ -0,0 +1,38 @@ +#include +#include +#include + +void help() { + printf("Commands\n'add' - Add two numbers together. Ex 'add 3 5'\n" + "'sub' - subtract two numbers. Ex 'sub 6 4'\n" + "'multi' - multiply two numbers. Ex 'multi 4 2'\n" + "'div' divide two numbers. Ex 'div 2 1'\n"); +} + +int add(const int numOne, const int numTwo) { + return numOne + numTwo; +} + +int main(void) { + while (1) { + char cmd[24]; + printf("Welcome to the BasicCalc, written in C\nBasic calculator functionality (add, subtract, multiply, and divide)\nType 'help' to begin!\n"); + scanf("%s", cmd); + + if (strcmp(cmd, "help") == 0) { + help(); + + } else if (strcmp(cmd, "add") == 0) { + char * args = strtok(cmd, " "); + while (args != NULL) { + int numOne = atoi(args[1]); + int numTwo = atoi(args[2]); + + int finalNum = add(numOne, numTwo); + printf("Your number is: %d", finalNum); + } + } + } + + return 0; +} \ No newline at end of file