Jan 31, 2012 at 2:06pm UTC
char* word = "abcdefgh";
can I do
int64_t i = *reinterpret_cast<int64_t*> (word)
and should the number be unique for different words?
Jan 31, 2012 at 2:09pm UTC
You should use the size_t data type instead of committing to using a 64-bit value. If you compile for 64-bit, size_t will be 64 bits.
EDIT: Scratch that. I just saw you are de-referencing.
Last edited on
Jan 31, 2012 at 2:13pm UTC
Jan 31, 2012 at 2:22pm UTC
actually, I do not want use a int64 if int32 will work. i am just not clear what is the max number a 8 letters word could be, including cap or not.
Jan 31, 2012 at 2:26pm UTC
8 chars are 8 bytes, or 64 bits. You can generate 32-bit numbers using only 4 letters. You can change to int if you like and it will continue to work, but the last 4 letters in your 8-letter example will go unused.
Jan 31, 2012 at 2:31pm UTC
thanks. I asked a dumb question :)