Here is my code:
Code:
double **double_array;
double_array = new double*[rows];
for(int i=0;i<rows;i++)
double_array[i] = new double[columns];
char split[3];
strcpy(split, ",;");
for(int i=0;i<rows;i++)
for(int j=0;j<columns;j++)
double_array[i][j] = charToDouble(strtok((i==0&&j==0)?&input[1]:NULL,split));
The rows and columns have already be determined to be positive nonzero integers (actually, they are 2 and 2). The char* input contains "[3,2;1,2]" (I called strcpy(input, "[3,2;1,2]")). When I run it through the MSVC++ 2005 debugger, it tells me that I have an access violation and the line that it points to is line 120 of strtok.c (included by the <string> header I assume), so I figure that there is something wrong with my call to strtok. This happens when i=j=0, but it might also happen afterwards (it never gets that far). charToDouble takes in a char* and returns a double. I should probably rename it to charArrayToDouble or stringToDouble.
Hopefully, I will figure it out the second I push the "Submit New Thread" button, as has happened before, but I doubt it. So here goes. Any ideas? Thanks in advance.