From 66951268ec5c61d94338ddea38eef51e7cd5dd52 Mon Sep 17 00:00:00 2001 From: Hyder Date: Tue, 22 Jul 2025 13:23:38 +0300 Subject: This is the file that i usually mess around with --- hi.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 hi.c (limited to 'hi.c') diff --git a/hi.c b/hi.c new file mode 100644 index 0000000..3d15edb --- /dev/null +++ b/hi.c @@ -0,0 +1,40 @@ +# include +# include + +// REUSABLE INTEGER ARRAY IN CASE YOU NEED AN INTEGER ARRAY +typedef struct { + int *data; + int size; + int capacity; +} IntArray; + +void initArray(IntArray *arr, int initialCapacity) { + arr->data = malloc(initialCapacity * sizeof(int)); + arr->size = 0; + arr->capacity = initialCapacity; +} + +void append(IntArray *arr, int value) { + if (arr->size >= arr->capacity) { + arr->capacity *= 2; + arr->data = realloc(arr->data, arr->capacity * sizeof(int)); + if (arr->data == NULL) { + printf("Reallocate failed!!\n"); + exit(1); + } + } + + arr->data[arr->size] = value; + arr->size++; +} + +int main () { + int x = 5; + int y = x++; + printf("%d\n", y); + y = ++x; + printf("%d\n\n", y); + + + return 0; +} \ No newline at end of file -- cgit v1.2.3