Onur Onur - 1 year ago 156
C++ Question

omitting the null string terminator in c++ string

In my little project, I am trying to hash some bitmaps and the bitmaps are like: "BMP1 /0 bitmap data". I am using a md5 hash library that I found on the internet and it works as simple as:

std::string md5(const std::string);

The problem is, since I have a string terminator in the middle of the memory, if I try to make a string from this memory, I can have only the first part and not the bitmap data. So, my question is, can I not finish the string here and take the whole data into it. Thanks in advance.

Answer Source

If you take a look at the constructors that std::string provides, you'll find that among the many constructors, besides the constructor that takes a null terminated string as an argument (5), there is a constructor that takes pointer to a character string, and a count of characters (4). The description mentions specifically that the pointed string may contain null characters. This means that the null characers do not terminate the string.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download