So I have something like this
#define HASHSIZE 1010081
static struct nlist *hashtab[HASHSIZE];
Now I want to be able to change the HASHSIZE of my hashtab, because I want to test different primes numbers and see which would give me less collisions. But Arrays do not take variable sizes so HASHSIZE has to be a constant. Is there a way to go about this?
Why don’t you use
std::vectorinstead of using arrays in C++?Eg:
But anyways you can do this if you are using
g++becauseg++supports Variable Length Arrays(VLAs) as an extension.Eg: