KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
In std::string there are only const members to fetch the data like c_str(). However I can get a reference to the first element of the string via operator[] and I can write to it. For example, if I have function: void toupper(char *first,char *last_plus_one); I can write directly to vector getting a pointer to the first element: vector<char> message // has "Some Message"; toupper(&message[0],&message[0]+message.size()); Can I do same thing with std::string? string message="Some Message"; toupper(&message[0],&message[0]+message.size()); Does the standard guarantee that the location of the memory is actually linear? ie: &(*(message.begin()+n)) == &message[n] Thanks.
Tags (comma-separated)
Save Edits
Cancel