char el[3] = myvector[1].c_str();
myvector[i] is a string with three letters in. Why does this error?
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.
It returns type char* which is a pointer to a string. You can’t assign this directly to an array like that, as that array already has memory assigned to it. Try:
But very careful if the string itself is destroyed or changed as the pointer will no longer be valid.