init
This commit is contained in:
16
.vscode/c_cpp_properties.json
vendored
Normal file
16
.vscode/c_cpp_properties.json
vendored
Normal file
@@ -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
|
||||||
|
}
|
||||||
6
.vscode/settings.json
vendored
Normal file
6
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"files.associations": {
|
||||||
|
"*.ejs": "html",
|
||||||
|
"stdio.h": "c"
|
||||||
|
}
|
||||||
|
}
|
||||||
3
Makefile
Normal file
3
Makefile
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
build:
|
||||||
|
mkdir -p bin
|
||||||
|
clang -O3 -o bin/cargon $(shell find src -name '*.c') -lncurses -Wall -Wextra -Werror
|
||||||
BIN
bin/cargon
Executable file
BIN
bin/cargon
Executable file
Binary file not shown.
21
src/cloneString/cloneString.c
Normal file
21
src/cloneString/cloneString.c
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#include "cloneString.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
8
src/cloneString/cloneString.h
Normal file
8
src/cloneString/cloneString.h
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
#ifndef CLONESTRING_H
|
||||||
|
#define CLONESTRING_H
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
char* cloneString(const char* str);
|
||||||
|
|
||||||
|
#endif // CLONESTRING_H
|
||||||
21
src/main.c
Normal file
21
src/main.c
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#include "cloneString/cloneString.h"
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
9
src/number/number.c
Normal file
9
src/number/number.c
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#include "number.h"
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
struct number translateNumber(char *code) {
|
||||||
|
struct number num;
|
||||||
|
num.sign = code[0] == '-' ? 1 : 0;
|
||||||
|
return num;
|
||||||
|
}
|
||||||
14
src/number/number.h
Normal file
14
src/number/number.h
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
#ifndef NUMBER_H
|
||||||
|
#define CLONESTRING_HNUMBER_H
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
struct number {
|
||||||
|
uint8_t sign;
|
||||||
|
uint64_t numerator;
|
||||||
|
uint64_t denominator;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct number translateNumber(char *code);
|
||||||
|
|
||||||
|
#endif // NUMBER_H
|
||||||
Reference in New Issue
Block a user