我试图声明一个指向二维浮点矩阵的指针,以便让我的图像数据具有动态行为,但我遇到了编译错误 C2057:预期的常量表达式。我认为必须以这种方式投射指针,但显然不是......请任何人都可以帮助我吗?谢谢!!
//Image size input
int imheight;
int imwidth;
cout << "Please, enter image height: \n>";
scanf ("%d",&imheight);
cout << "Please, enter image width: \n>";
scanf ("%d",&imheight);
const int imheight2 = imheight;
const int imwidth2 = imwidth;
float *zArray[imheight2][imwidth2];
这是我试图访问 zArray 的其他功能之一。我没有正确读取数据:
void LoadRIS( char* inputFileName , float** zArray, int imageHeight , int imageWidth){
// Load input RIS file
FILE* lRis = fopen ( inputFileName, "rb" );
// Jump to data position
for (int i = 0; i < 88; i++){
uchar a = getc (lRis);
}
// Read z array
size_t counter = fread ( *zArray , 1 , imageHeight * imageWidth * sizeof(zArray) , lRis );
//Get max value of RIS
float RISmax = zArray [0][0];
float RISmin = zArray [0][0];
for (int i=0; i<imageHeight; i++)
{
for (int j=0; j<imageWidth; j++)
{
if (zArray[i][j] > RISmax)
RISmax = zArray [i][j];
if (zArray[i][j] < RISmin)
RISmin = zArray [i][j];
}
}
std::cout<<"The max value of the RIS file is: "<<RISmax<<"\n";
std::cout<<"The min value of the RIS file is: "<<RISmin<<"\n";
Beep(0,5000);
// Close input file
fclose (lRis);
}