c++ - std::string or std::vector<char> to hold raw data -


i hope question appropriate stackoverflow... difference between storing raw data bytes (8 bits) in std::string rather storing them in std::vector<char>. i'm reading binary data file , storing raw bytes in std::string. works well, there no problems or issues doing this. program works expected. however, other programmers prefer std::vector<char> approach , suggest stop using std::string it's unsafe raw bytes. i'm wondering why might unsafe use std::string hold raw data bytes? know std::string used store ascii text, byte byte, don't understand preference of std::vector<char>.

thanks advice!

the problem not whether works or doesn't. problem is utterly confusing next guy reading code. std::string meant displaying text. reading code expect that. you'll declare intent better std::vector<char>.

it increases wtf/min in code reviews.


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -