I'm trying to use MurmurHash (returning 64 bit hashes on a 64bit comoputer) and have sent it the simple 3 letter string 'yes' as follows
char* charptr = "yes";
cout << MurmurHash64A(charptr, 3, 10);
(where 3 is the length and 10 is the seed) This gives a 64bit hashed response as expected, I can set up more pointers to C strings holding yes and they all return the same hashed value.
But if I try to sending it a C++ string:
string mystring = "yes";
string* strptr = &mystring;
cout << MurmurHash64A(strptr, 3, 10);
...I get a different result to the C string method, what's more if I set up several of these strings in the same way, they all give different results. This suggests to me that strings are maybe not stored in contiguous memory locations, some Googling backed this up. So I then tried to set up a vector in dynamic memory as this was the only way I could think of to force contigous memory. Just like the C++ string method it returned a different result from the C string method and when I set up several they all return a different result from each other. I set them up like follows:
char yes[3] = {'y', 'e', 's'};
vector<char> *charvec = new vector<char>;
void* myvecptr3 = &charvec;
charvec->reserve(3);
charvec->push_back(yes[0]);
charvec->push_back(yes[1]);
charvec->push_back(yes[2]);
As I understand it my char vector will start at the address the vector is given and fill consecutive bytes with my three characters in the same way as a C string. I am confused why I'm getting different results, any help appreciated? Thanks C