aboutsummaryrefslogtreecommitdiff
path: root/hi.c
diff options
context:
space:
mode:
authorHyder <hyder@hyderhadi.xyz>2025-07-22 13:23:38 +0300
committerHyder <hyder@hyderhadi.xyz>2025-07-22 13:23:38 +0300
commit66951268ec5c61d94338ddea38eef51e7cd5dd52 (patch)
tree49bac52ad3b83f61dcad422a8ece651c2d4ade4d /hi.c
parentcc5080504ad9a9d5726be8e74d09fb54171e2973 (diff)
This is the file that i usually mess around with
Diffstat (limited to 'hi.c')
-rw-r--r--hi.c40
1 files changed, 40 insertions, 0 deletions
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 <stdio.h>
+# include <stdlib.h>
+
+// 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