I have a char vector with text in it.
I'd like to split it into strings at every new line.
Is it better to assign the vector to a string first or is there a function that can do this with the vector?
I have a char vector with text in it.
I'd like to split it into strings at every new line.
Is it better to assign the vector to a string first or is there a function that can do this with the vector?
Using Windows 10 with Code Blocks and MingW.
Of course you can do this with the vector directly: it's a matter of finding the new line sequence, and then constructing a string from a starting index to the index of the new line sequence.
On the other hand, it might be easier with a std::string object. Since you're going to treat the data like a string anyway, why not use a std::string instead of a vector of char to begin with?
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
My vector is used as an unsigned char array, I guess I could assign a string object to an unsigned char array too.
Thank you laserlight.
Using Windows 10 with Code Blocks and MingW.