存储大小未知
Storage size isn't known
const int MAXWIDTH = 512;
const int MAXHEIGHT = 512;
void readImage(int image[][MAXHEIGHT], int &width, int &height)
....
void writeImage(int image[][MAXHEIGHT], int width, int height)
....
int main ()
{
int image[][MAXHEIGHT], width, height;
readImage (image, &width, &height);
writeImage (image, width, height);
return 0;
}
我一直在主函数中得到"'图像'的存储大小未知",不知道为什么。
除非
使用初始值设定项列表,否则在声明数组时无法执行int image[][MAXHEIGHT];
。
int image[][5]={ {1,2,3,4,5},{6,7,8,9,10} };//is OK and the compiler get the row size from your initializer list and creates image[2][5]
int image[][5];//this is not OK because the compiler can't know the size of the row when creating the arrray
int image[MAXWIDTH][MAXHEIGHT];//OK because you specified both dimensions
指定函数的形式参数时,可以保留二维数组的行维数。
void somefunction(image[][MAXWIDTH])//is OK
相关文章:
- 将字符串存储在c++中的稳定内存中
- std::原子加载和存储都需要吗
- C++:将控制台输出存储在宏中更好吗
- 如何存储未知次数迭代的输入?
- C++:将未知类型的对象存储为成员变量的类
- 获取由空格分隔的未知大小的单行输入,并将其存储到整数数组中
- typedef struct vs struct - "struct"的存储大小未知
- Eigen:如何将未知大小的矩阵存储为类中的成员
- "vector"的存储大小未知
- 让班级存储未知数据
- 存储大小未知
- 我正在尝试通过 Boost 图形库从 Graphviz DOT 文件中读取图形.如何读取存储在数组中的未知数量的属性
- 使用以前未知的模板存储通用对象
- 在输入过程中,将字符串存储在大小未知的向量中
- Swig-存储未知对象,直到下次调用C++函数
- 从未知数量的文件中存储数据
- c++存储指向未知类成员函数的指针
- 如何在数组中存储大量未知长度
- 如何在数组C++中存储未知数量的元素
- 在c++中存储未知大小的表