So, I have a class
class MySuperClass { public: std::string buffer; }; And wants to print buffer to std::cout. Here's some code about filling string from a file:
MySuperClass msc; std::fstream file("./favicon.ico", std::fstream::in | std::fstream::binary); if (file.is_open()) { std::stringstream ss; while (!file.eof()) ss << static_cast<uint8_t>(file.get()); msc.buffer.assign(ss.str()); file.close(); } When I output string, all ok. It prints messy, but something. But when I call c_str() on the buffer and try to print, it prints nothing.