Hi,
I'm trying to convert my string into a dynamic array of doubles. Each space of my string represents a column, each ";" represents a new row. When this code runs, it only works for when *F[0][col]. When it gets to *F[1][col] it gives me the error "Unhandled exception at 0x00e4483c in CCode.exe: 0xC0000005: Access violation reading location 0xcccccccc." Anyone know why?
void main(void) {
double **F = NULL;
F = malloc(row * sizeof (double *));
for (m=0; m < row;m++) {
F[m] = malloc(col * sizeof(double ));
}
FParser(string, &F);
for (m=0;m<rowF;m++)
free(F[m]);
free(F);
}
void FParser(char string[256], double ***F) {
while (dummyChar_ptr != NULL) {
dummyChar_ptr = strtok(dummyChar_ptr," ");
while ((dummyChar_ptr) != NULL) {
*F[row][col] = atof(dummyChar_ptr);
dummyChar_ptr = strtok(NULL," ");
col++;
}
col=0;
row++;
strcpy(dummyChar,string);
dummyChar_ptr = strtok(dummyChar,";");
for (x=0;x<row;x++)
dummyChar_ptr = strtok(NULL,";");
}
//example String: 1 0.1 0 0; 0 1 0 0; 0 0 1 0.1; 0 0 0 0.1