I need to create a function that turns a string into a vector of characters with each character holding a place in the vector. Anyone know how I can do this?
Create a loop, that will loop the string.
vector.push_back( string[ index ] ) to the vector.
Thanks, are strings stored as sequences of chars in the computer's memory?
@Catfish, your solution works fine! And thanks! lol. I love trying to help someone, but end up learning! (:
represent the first and last characters in the string?
std::vector<char> v( s.begin(), s.end() )
is creating the vector starting with the first character and ending with the last character?
> Thanks, are strings stored as sequences of chars in the computer's memory?
Stored as sequence of characters in the memory provided by the allocator.
That this sequence of chars must be stored contiguously was added in 2003.
OK, that makes sense.
Just an observation, why bother doing this when you can just use the string in the same manner as you would a vector. e.g.