Why are are these re-cast string types returning different data?

  arrays, c++, string

I’m reading a ‘qbytearray’ string from a text file that I don’t have control over.
I’m not using Qt.

But this way of handing the string in the text file works in my program:

unsigned char* apa = (unsigned char*)"xf1`xf9a\x9cTx82zx17x5xb9xbcx60xcax15";

but this does not work:

unsigned char* apa = (unsigned char*)settings_in.at(1).c_str();

(yep I have double checked the contents of the std::string settings_in)

Why are these different?
And how could I achieve the top result with a std::string?

Source: Windows Questions C++

LEAVE A COMMENT