• Advertisement
Sign in to follow this  

Problem when reading from buffer

This topic is 1410 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How should I go about reading from an unsigned char array,given that I know the size? Suppose it contained:

 

word

word1

 

I would need to read every word into a separate string. The obvious way is to just loop through it,test if the char is whitespace and go from there.... but I would like to use the std functions...

Edited by noatom

Share this post


Link to post
Share on other sites
Advertisement
Reading into what?

You are looking at c-style strings in a buffer. Perhaps a stringstream object might be appropriate? stringstream provides lots of useful ways of turning buffers into objects with buffer-style manipulations, stream-style manipulations, and string-style manipulations. Also if you are looking at strings alone, the string constructors might be useful, as might string::append, string::insert and string::assign.

Share this post


Link to post
Share on other sites

ok,let me make it more concise:

 

if I had: "today is a good day" put into an unsigned char array, how would I go about puting every single word into a separate std::string?

 

 

UPDATE: used stringstream as you suggested,and it worked just fine,thanks.

Edited by noatom

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement