I got a problem in my code by allocating a two-dimensional array for double values. So first the code I use:
double** matrix;
double ncolumn=2;
double nrow;
for (size_t i=0; i<nSlices; ++i) {
const std::vector<LineSegment> &lss = slicesWithLineSegments[i];
//I use
nrow = lss.size();//Returns the numbers ob Row;
matrix = malloc(nrow*sizeof(double*));
for (size_t j=0; j<nrow; ++j)
{
matrix[j] = malloc(ncolumn * sizeof(double));
}
}
Since I have a number of segments, and each segment has a different number of lines, I have to edit the array for each segment. That's why i use the for-loop with nSlices.
But in the two lines with the malloc commands I get a error from visual studio. Here's the error-message:
error C2440: '=' : cannot convert from 'void *' to 'double *'
error C2440: '=' : cannot convert from 'void *' to 'double *'
IntelliSense: a value of type "void *" cannot be assigned to an entity of type "double **"
IntelliSense: a value of type "void *" cannot be assigned to an entity of type "double *"
I also tried to use calloc, but I also got this error messages. I also had a look on google, and just found the code in the way I did it. But the errors still remain.