I think this is correct but i wanted to be sure, I'm wanting someone to tell
me if I'm doing the array allocation and deallocation correctly.
int i, wc = 0;
char *vptr;
char **Array;
Array = malloc(sizeof(c har **));
while(some condition)
{
vptr = some char array with a length 1 and 20 bytes
Array = realloc(Array, sizeof(char**)* wc+1);
Array[wc] = malloc(strlen(v ptr)+1);
strcpy(WordArra y[wc], vptr);
wc++;
}
// then later on
for(i=0; i<wc; i++)
free(Array[i]);
free(Array);
go for liftoff?
Thanks
Eric
me if I'm doing the array allocation and deallocation correctly.
int i, wc = 0;
char *vptr;
char **Array;
Array = malloc(sizeof(c har **));
while(some condition)
{
vptr = some char array with a length 1 and 20 bytes
Array = realloc(Array, sizeof(char**)* wc+1);
Array[wc] = malloc(strlen(v ptr)+1);
strcpy(WordArra y[wc], vptr);
wc++;
}
// then later on
for(i=0; i<wc; i++)
free(Array[i]);
free(Array);
go for liftoff?
Thanks
Eric
Comment