Represent a four letter word as a number I am trying to do some things in mysql and c++, and I wonder, is there a way to convert a word to a number such that I can recover the word from the value of the number?
Each word represents an ID for a station in a geographic location somewhere in the world.  I am searching for missing values and going to replace using cubic spline, least squares, etc.  But I need to keep track of where to insert the replaced number in the sql table when I am done.  Each word is exactly 4 letters and unique, so I thought that this should be possible.
 A: One (Standard) way you could do this could be to convert all characters into their respectice ASCII code. So a would correspond to 97. The word cat would be 99 97 116 or 099097116 (insert the two zeros so that each three digits of the number corresponds to a character). The nice things about this is that it is very easy to do in C++. This might not be what you actually want, but since it is unclear what you are trying to achieve, it is hard to give a good answer.
Another way would be to create an array X[]  and read a (precreated) dictionary into the array. So that $X[44]$ would be the 44th word on the list. 
A: Probably the easiest way as far as the machine is concerned is to convert your array of 4 ASCII characters (assuming they are one-byte) into an integer simply by casting the pointer to the array of 4 characters into an int pointer and then printing out the dereferenced value of the integer. Then to convert back, read in the integer and make an integer pointer point to it, then convert the pointer to a character pointer and print out the 4 characters as elements of a character array with that pointer. This will work with 8-bit characters and 32-bit integers.
