RSS
 

Posts Tagged ‘string’

c++ std::string

10 Jul

the c++ string or more specifically std::string is a great improvement over the c-strings which are null terminated. c++ strings use a length fields to keep track of how long the string is as compared to c-string which use the NULL ‘\0′ character to keep track of where the string ends.

The c-strings have been around for so long and are used in so many places that when people start to use the std::string they get confused. For example today i wanted to use std::string to hold binary data, i knew that this was possible but i couldn’t figure out how. Then stack overflow came to the rescue. This question is explained very well there.

Thanks Stack Overflow :)