I’ve been looking into using C over C++ as I find it cleaner and the main thing I find it to lack is a vector like array.
What is the best implementation of this?
I want to just be able to call something like vector_create, vector_at, vector_add, etc.
EDIT
This answer is from a million years ago, but at some point, I actually implemented a macro-based, efficient, type-safe vector work-alike in C that covers all the typical features and needs. You can find it here:
https://github.com/eteran/c-vector
Original answer below.
What about a vector are you looking to replicate? I mean in the end, it all boils down to something like this:
You could wrap this all up in a struct, so it "knows its size" too, but you’d have to do it for every type (macros here?), but that seems a little uneccessary… Perhaps something like this:
After which, you could do:
I dunno, it just doesn’t seem worth the effort.