I'm trying to store an array of string in a double pointer but it doesn't seem to be doing so.
char **pointerA;
char *pointerB;
int count;
FILE* file = fopen("textfile.ini", "r");
pointerA = (char **) malloc (sizeof(*pointerA));
pointerB = (char *) malloc (sizeof(*pointerB));
while(fgets(pointerB, 200, file) !== NULL)
{
pointerA = (char **)realloc(pointerA, sizeof(char *) * (strlen(pointerB) + 1));
pointerA[count] = pointerB;
count++;
}
fclose(file);
I expect every element to only store it's own string but it seems like all the element is storing the last string.