Archived

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

Metro_Mystery

2 stupid questions...

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