It returns a char * type, which is a pointer to a string. You cannot assign it directly to an array, since this array already has memory assigned to it. Try:
const char* el = myvector[1].c_str();
But be very careful if the string itself is destroyed or changed, because the pointer will no longer be valid.
source
share