我需要一个简单c结构的帮助,但无法找到它为什么不编译使用gcc(opensuse 11.4)
我有这个代码:
struct Image {
int w;
int h;
// other code
};
Run Code Online (Sandbox Code Playgroud)
在同一个文件中,我有另一个结构数组,如下所示:
struct ShapeImage
{
Image image[10];
// other code
};
Run Code Online (Sandbox Code Playgroud)
当我编译时,我得到:
syntax error before [' token`
Run Code Online (Sandbox Code Playgroud)
为什么我收到此错误如果指定图像中的数字10 image[10];看起来对我好,有什么问题?
Adi*_*idu 16
它应该是:
struct Image image[10] ;
Run Code Online (Sandbox Code Playgroud)
或者在定义结构时使用typedef:
typedef struct {
int w;
int h;
// other code
} Image;
Run Code Online (Sandbox Code Playgroud)
并使用与您的问题相同的代码.