So what are main differences and which of them will be used in which cases?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
vector<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*tovector<char>pop_back()orback()functionsc_str()Bottom line: Use
stringwhen you need to operate with strings. Usevector<char>when you need a … well, vector of individual chars…Another use of
vector<char>is a way to avoidvector<bool>specialization.