[Solved] Convert string to char in c++ no complete process


Just a wild guess based on the symptoms only.

A c++ string is a much more complex object than is a mere C char *. In this particular use case, it has a true length and can contain NULL characters, whereas by convention a C string (char *) is ended with a NULL. That means that every C string can be converted to a C++ std::string, but the opposite is only true if the std::string does not contain any NULL.

If you need to process the std::string as a char array, you need to use Image_Content.data() or Image_Content.c_str() (*) and use first Image_Content.size() characters from it. That just means that a printf on it will be truncated at first NULL, even if other characters exist after it.

(*) as noticed by @atkins both methods are synonyms for C++11. For C++98, both gave access to the full buffer, by only c_str was guaranteed to be null terminated.

6

solved Convert string to char in c++ no complete process