2013-09-24 54 views
0
#define MAXLINELENGTH 8192 

struct Image { 
unsigned int height; 
unsigned int width; 
unsigned int value; 
unsigned int maxValue; 
unsigned int data[MAXLINELENGTH]; 
}; 


Image *Image_Init() 
{ 
    Image *tmpImage; 
    unsigned int data[MAXLINELENGTH]; 
    //if(tmpImage != NULL) 

    //{ 
    tmpImage->height = 0; 
    tmpImage->width = 0; 
    tmpImage->value = 0; 
    tmpImage->maxValue = 0; 
for (int i = 0; i < MAXLINELENGTH; i++) 
{ 
    tmpImage -> data[i] = data[i]; 
} 
//tmpImage.data = {}; 
//return &tmpImage; 
//} 

return tmpImage; 
    } 

unsigned int Image_Get_Height (Image *img) 
{ 
Image *tmpImage; 
int UINT_MAX; 
UINT_MAX = tmpImage.height; 

//int UINT_MAX; 
//UINT_MAX = img.height; 
return UINT_MAX; 
} 

發生錯誤,我不知道如何解決它。非班級類型錯誤

C:73:錯誤:請求部件「tmpImage」,其是非類類型「圖片*」

爲solvingthis錯誤請幫助的「高度」。

+1

哪一行是73行? –

回答

1
Image *tmpImage; 
/* ... */ 
UINT_MAX = tmpImage.height; 

這裏有兩個問題。首先是你的點語法錯誤.訪問成員的指針結構的成員,所以你應該使用->

第二個問題更嚴重,那就是你將使用一個未初始化的指針,這可能(並可能會)在運行程序時導致崩潰。

1

UINT_MAX是一個標準的DEFINE,而且它是一個不可修改的值,即使int UINT_MAX是無效的,因爲UINT_MAX將implemantions最大的整數值進行更換,所以你會說

unsigned int Image_Get_Height (Image *img) 
{ 
    Image *tmpImage; 
    int 4294967295; 
    4294967295= tmpImage.height; 

    //int UINT_MAX; 
    //UINT_MAX = img.height; 
    return 4294967295; 
} 

,這是不是有效;)

錯誤它的自我只是說,你試圖通過一個點.進入電影的結構指針成員什麼是不對的,因爲它作爲道上約阿希姆Pileborg他回答說是與->運營商訪問。

相關問題