I have to store some char arrays in an array. But I don't know how many of them I will have to store.
What would be the best: initializing my array with a small size (like 1) and then realloc everything? How am I supposed to use realloc or malloc?
I cannot use vectors nor stl containers nor strings unfortunately. Increasing the size of a vector is very easy and I tried to understand malloc and realloc but I don't...
char ** array=(char**)malloc(10*sizeof(char*));
for (int i=0;i<10;i++)
array[i]="10";
array=(char **)realloc(array,(sizeof(array)+1)*sizeof(char*));
array[10]="12";
I understood the basic principle yes. Is it in this way?