can I reinterpret any 8 letters word to a number?


char* word = "abcdefgh";

can I do

int64_t i = *reinterpret_cast<int64_t*> (word)

and should the number be unique for different words?


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
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.
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.
thanks. I asked a dumb question :)
Topic archived. No new replies allowed.