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;
}

there is an error occurred and i have no idea about how to fix it.

c:73: error: request for member 'height' in 'tmpImage', which is of non-class type 'Image*'

Please help for solvingthis error.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621

2 Answers2

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

Here you have two problems. The first is the syntax error that you a dot . to access the member of a pointer to a structure, so you should be using ->.

The second problem is more serious, and that is that you will then be using an uninitialized pointer, which might (and probably will) cause a crash when running the program.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
1

UINT_MAX is an standard DEFINE, and it is an not modifiable value, even int UINT_MAX isn't valid, as UINT_MAX will be replaced by implemantions greatest integer value so you would say

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

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

and this is not valid ;)

The error it self is just saying that you try to acces a structure pointer member by a dot . what is not right, as it hast to be accessed with -> operator as Joachim Pileborg said in his answer.

dhein
  • 6,431
  • 4
  • 42
  • 74