Last active
January 31, 2024 08:24
-
-
Save DenisBelmondo/a1db7054fd94c044a631359b8a8110a0 to your computer and use it in GitHub Desktop.
c89 type safe dynamic array (test bed)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include "array.h" | |
typedef Array(int) IntArray; | |
int main(void) { | |
IntArray a; | |
size_t i; | |
array_init(&a); | |
array_push_back(&a, 128); | |
array_push_back(&a, 256); | |
array_push_back(&a, 1); | |
array_push_back(&a, 2); | |
array_push_back(&a, 3); | |
array_push_back(&a, 1); | |
array_push_back(&a, 2); | |
array_push_back(&a, 3); | |
array_push_front(&a, 512); | |
for (i = 0; i < a.count; i++) { | |
printf("%d\n", a.data[i]); | |
} | |
printf("%zu\n", a.capacity); | |
array_deinit(&a); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment