Jump to content
  • Advertisement

Archived

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

Metro_Mystery

2 stupid questions...

This topic is 5306 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

Assuming x is an integer variable- to get the byte length you can use... SizeOfInt = sizeof(x); SizeOfInt = sizeof x; or directly -> SizeOfInt = sizeof int; but why can''t you use -> SizeOfInt = sizeof int; I think this has something to do with operator precedence, but I''m not sure... any ideas? Also, this makes absolutely no sense... but it''s just out of curiousity- that aside... Say I have a character array that I want to have store the word ''GAME''- I''ll have the first character, ''G'' and the last two, ''M'' and ''E'' initialized as character literals in the definition- but how would I store the ''A'' in the string using the hex equivalent of 0x41. For example, this doesn''t work- but it''s what I''m aiming at... char TestArray[5] = "G\0x41ME"; Anyone know how I could write it in such a stupid form?

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
>or example, this doesn''t work- but it''s what I''m aiming at...
>
>char TestArray[5] = "G\0x41ME";

char TestArray[5] = "G\x41ME"; // \x instead of \0x

Share this post


Link to post
Share on other sites
I have no idea what you''re asking for the first question.

For the second question you can use the \x escape sequence. e.g.:
char TestArray[5] = "G\x41ME";

Share this post


Link to post
Share on other sites
quote:
Original post by Metro_Mystery
Also, this makes absolutely no sense...
Agreed. Why don't you stick to sizeof(int)?

[edited by - Cedric on January 5, 2004 9:24:53 AM]

Share this post


Link to post
Share on other sites

  • 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!