diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..07c08df --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,16 @@ +{ + "configurations": [ + { + "name": "Linux", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [], + "compilerPath": "/usr/bin/clang", + "cStandard": "c17", + "cppStandard": "c++17", + "intelliSenseMode": "linux-clang-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..1de26dd --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "files.associations": { + "*.ejs": "html", + "stdio.h": "c" + } +} \ No newline at end of file diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..55f193d --- /dev/null +++ b/Makefile @@ -0,0 +1,3 @@ +build: + mkdir -p bin + clang -O3 -o bin/cargon $(shell find src -name '*.c') -lncurses -Wall -Wextra -Werror \ No newline at end of file diff --git a/bin/cargon b/bin/cargon new file mode 100755 index 0000000..63179c3 Binary files /dev/null and b/bin/cargon differ diff --git a/src/cloneString/cloneString.c b/src/cloneString/cloneString.c new file mode 100644 index 0000000..ec035db --- /dev/null +++ b/src/cloneString/cloneString.c @@ -0,0 +1,21 @@ +#include "cloneString.h" + +#include +#include +#include + +char* cloneString(const char* str) { + if (str == NULL) { + return NULL; + } + + size_t len = strlen(str); + char* clone = malloc((len + 1) * sizeof(char)); + + if (clone == NULL) { + return NULL; + } + + strcpy(clone, str); + return clone; +} diff --git a/src/cloneString/cloneString.h b/src/cloneString/cloneString.h new file mode 100644 index 0000000..ae093d6 --- /dev/null +++ b/src/cloneString/cloneString.h @@ -0,0 +1,8 @@ +#ifndef CLONESTRING_H +#define CLONESTRING_H + +#include + +char* cloneString(const char* str); + +#endif // CLONESTRING_H diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..440eb2f --- /dev/null +++ b/src/main.c @@ -0,0 +1,21 @@ +#include "cloneString/cloneString.h" + +#include +#include + +int main() { + const char* str = "Hello, World!"; + char* clone = cloneString(str); + + if (clone == NULL) { + printf("Failed to clone string\n"); + return 1; + } + + printf("Original string: %s\n", str); + printf("Cloned string: %s\n", clone); + + free(clone); + + return 0; +} \ No newline at end of file diff --git a/src/number/number.c b/src/number/number.c new file mode 100644 index 0000000..861eb98 --- /dev/null +++ b/src/number/number.c @@ -0,0 +1,9 @@ +#include "number.h" + +#include + +struct number translateNumber(char *code) { + struct number num; + num.sign = code[0] == '-' ? 1 : 0; + return num; +} diff --git a/src/number/number.h b/src/number/number.h new file mode 100644 index 0000000..0e93d1e --- /dev/null +++ b/src/number/number.h @@ -0,0 +1,14 @@ +#ifndef NUMBER_H +#define CLONESTRING_HNUMBER_H + +#include + +struct number { + uint8_t sign; + uint64_t numerator; + uint64_t denominator; +}; + +struct number translateNumber(char *code); + +#endif // NUMBER_H