&pImage->sizeY == 0 even if &pImage + 4 points to the sizeY variable in pImage

Started by
2 comments, last by dreddlox 22 years, 1 month ago
How do I find the address of the element ''sizeY'' in the struct pImage in C++? I tried &pImage->sizeY and it compiled right, but memory violations and the debugger says it points to 0x00000000
Advertisement
Try using parenthesis to wrap the member &(pImage->sizeY)
"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man
And what address does pImage point to? If you have memory violations with that code I assume you haven''t allocated memory for pImage or pImage is pointing to something it shouldn''t be pointing to.
Redemption: the pImage pointer is fine, properly allocated with new or malloc(depending on how well my day is going), so my makeshite solution was &pImage + 4(as there was 1 int between &pImage and &sizeY)

LessBread: Thanks, it worked :-)

This topic is closed to new replies.

Advertisement