Hi, I really can't figure this one out. Please, anyone with an idea please
help, here is some code.
// Get conductivities.
*k = strtod(args[0], &end);
*R = strtod(args[1], &end);
printf("%s\n", args[0]);
printf("%s\n", args[1]);
printf("%u\n", &args[0]);
printf("%u\n", &args[1]);
// Clear out the args array of pointers.
for (i = 0; i < numArgs; i++)
{
printf("%d\n", i);
free((args)[i]);
printf("yo\n");
}
Output:
0.5
0.75
4017344
4017348
0
yo
1
A little explanation: args is a (char **) and I'm using malloc and realloc to
allocate the memory, I've checked that numArgs is equal to 2. Also I know
args[1] is properly allocated because the address looks right as well as the
fact is that it's printing out 0.75 which is the proper string that should be
there. The problem occurs when I try to free args[1] in the for loop as you can
see from the output. The error I'm getting says 'The memory could not be
"read"' which I understand is windows way of telling me I have a seg fault, but
I just can't figure where on this one.
Any help is appreciated. Thanks ahead of time.
JBA