Jump to content
  • Advertisement
Sign in to follow this  
Yohomyth

if( *( (WORD*)hStrTbl + 8 ) = wID )

This topic is 4958 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm using VC6 and I have a strange problem. if( *( (WORD*)hStrTbl + 8 ) <= wID ) this should come out false because wID is 0 and the value at hStrTbl+8 should be 800. i think the problem is how i typed this but i can't figure it out! any help is appreciated [Edited by - Yohomyth on April 25, 2005 4:26:33 PM]

Share this post


Link to post
Share on other sites
Advertisement
What exactly are you trying to do? Your casting hStrTbl to a word, then adding 8 to this address... not eight bytes, but 8 WORDS (16 bytes):P. So, it's the same as doing:

((WORD*)hStrTbl)[8] <= wID

Or at least that's what it looks like to me, unless I'm missing something. Why are you even casting it like that? Why not just do this:

if (*((WORD*)(&hStrTbl[8]) <= wID)

I'm assuming hStrTbl is a char array?

WORD* wordStrTbl = (WORD*)hStrTbl;
if (wordStrTbl[4] <= wID) //WORD is 2-bytes, so to add 8, we need to access array 4

Please describe what exactly you're trying to accomplish, and why you are needing this cast? There is probably a simpler way around this, or at least a more legible way :)

Share this post


Link to post
Share on other sites
it worx! thank you

hStrTbl was defined as HANDLE and I was trying to read a DWORD 10 bytes after it.

[Edited by - Yohomyth on April 25, 2005 5:40:27 PM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!