Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3279880
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:38:31+00:00 2026-05-17T19:38:31+00:00

I’m trying to use MurmurHash (returning 64 bit hashes on a 64bit comoputer) and

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T19:38:32+00:00Added an answer on May 17, 2026 at 7:38 pm

    &mystring points at the string object. You want to use mystring.c_str() to get a pointer to a raw character array.

    For the vector, you want &(*charvec)[0]. But you probably don’t want to use new; you could just do vector<char> charvec; void *myvecptr3 = &charvec[0];.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.