Archived

This topic is now archived and is closed to further replies.

Mansion

array and LPDIRECTDRAW7

Recommended Posts

Mansion    122
why doesnt this work? typedef struct tsth{ LPDIRECTDRAWSURFACE7 srf; }sth; sth image; LPDIRECTDRAWSURFACE7 surface; LPDIRECTDRAWSURFACE7 array[1]; .. surface = DDLoadBitmap...etc array[0] = surface; //this line doesnt work img->srf = array[0]; anyone?

Share this post


Link to post
Share on other sites
Xai    1838
The answer is the line should read:
image.srf = array[0]; // notice not img AND . instead of ->

since image is a struct (not a pointer to a struct) you use the .(dot) operator to access it''s members.

BTW ... are you using C or C++??? you wrote your struct definition in old C style NOT C++ ... in c++ it should be like this:

struct sth{
LPDIRECTDRAWSURFACE7 srf;
};


notice ... no typedef ... and no name following the end brace ... the name gets assigned from the one given between the word struct and the opening brace .. just like classes ...

good luck

Share this post


Link to post
Share on other sites
Mansion    122
i typed wrong in my example i use -> bcos ''image'' is pointer so..

sth *image;

//this doesnt work
image->srf = array[0];

what about this?

Share this post


Link to post
Share on other sites