Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

std::string equivalent for data with null characters?

I'd like to read a binary file and use something like std::string that automatically resizes the buffer and such.

I'm using Visual C++. What are my options?

like image 381
known Avatar asked Nov 28 '22 19:11

known


1 Answers

The std::string class already does handle data with embedded NUL characters. What problem are you encountering?

Note that when using the .c_str() method, any embedded NUL character will terminate the returned C-style string.

like image 166
Greg Hewgill Avatar answered Dec 05 '22 07:12

Greg Hewgill