Hi all,
I am trying to malloc some memory and then pass the address of the first array into another function however I keep getting the same error (see thread name).
Error:error C2664: cannot convert parameter 1 from 'float **__w64 ' to 'float *
Here is a short version of my code that repeats the same error.
void vGetPixelValueIntoArray(float *,const char*, s_Header*);
int main(int argc, char **argv) {
float **ppfImageData = 0;/* a pointer to a series of 2d arrays */
s_Filename *psFile;
s_Header *psHeader;
float *pfResFunc;
size_t nCountI,nCountJ;
if(!(ppfImageData = (float **) malloc(psHeader->nPhotosToBeCounted))){
fprintf(stderr, "Failed to allocate memory for imageMatrix array!\n");
return NULL;
}
nCountI = 0;
vGetPixelValueIntoArray(&ppfImageData[nCountI], "c:\testfile.ppm", psHeader); //parameter 1 that causes the problems
for (nCountJ=0; nCountJ<psHeader->nPhotosToBeCounted; nCountJ++){
free(ppfImageData[nCountJ]);
}
free(ppfImageData);
return 0;
}
void vGetPixelValueIntoArray(float *pfImageData, const char* pccFilename, s_Header* psHeader ) {// returns NULL if error
size_t nCounter, nSecondCounter;
FILE *pFTemp_file;
//float *pfImage;
psHeader->nWantedPixels = 5; //Hack to only take in certain amount of pixels
if (!(pFTemp_file = fopen(pccFilename,"rb"))){ //open file
fprintf(stderr, "Can't open file!\n");
exit(-1);
}
if (!(pfImageData = (float *) malloc(psHeader->nWantedPixels))){ //malloc array for image data
fprintf(stderr, "Failed to allocate memory in *pfGetPixelValueIntoArray");
exit(-1); //cant return a null >???? need a error function
}
for(nSecondCounter=0;nSecondCounter<psHeader->nHeaderEnd;nSecondCounter++){fgetc(pFTemp_file);}
for (nCounter=0; nCounter<psHeader->nWantedPixels; nCounter++){
pfImageData[nCounter] = (unsigned char) fgetc(pFTemp_file);
//skip next two values are they make up the rgb pixel and are therefore not needed
//only do this if there are pixels to jump over and if it is a 3 channel operation
fgetc(pFTemp_file);
fgetc(pFTemp_file);
if (feof(pFTemp_file)) break;
}
fclose(pFTemp_file);
}
What happens in function vGetPixelValueIntoArray is not really important as its the call line for this in Main that causes the error :(.
Any advice would be appreciated.