So what are main differences and which of them will be used in which cases?
See Question&Answers more detail:osSo what are main differences and which of them will be used in which cases?
See Question&Answers more detail:osvector<char>
gives you a guarantee that &v[0]+n == &v[n]
whereas a string doesn't (practically, it is the case, but there is no guarantee)... AFAIK C++0x gives that guarantee alreadyconst char*
to vector<char>
pop_back()
or back()
functionsc_str()
Bottom line: Use string
when you need to operate with strings. Use vector<char>
when you need a ... well, vector of individual chars...
Another use of vector<char>
is a way to avoid vector<bool>
specialization.