I am currently learning and using C++-style strings from the std::wstring class.
More recently, in a program someone else wrote, I was confrontated with stringbuf(typedef basic_stringbuf<char>) class.
Can someone explain me what is concretely a stream buffer, what is the difference between it and a simple string?
I was thinking about it as a kinf of array that can buffer several strings.
My problem is then how to extract the elements of this array separately.
The question was posed when trying to get serial data. The data is written byte after byte into the buffer. But then I need to get back all those bytes separately. I have not found the apropriate method to doing that.
Bazzy I have seen those page on the site, but what I cannot understand us what are stringstream. In two words, when and how to use them.
Does it suit for my needs of getting serial data?
And how to separate the received bytes?
As cin/cout are streams that work on standard input/output and fstreams are streams that work on files, stringstreams are streams which work on strings.
You need to use stringstreams when you want to have the stream I/O operations on a string.
To get characters (byte) from a string the simplest way is using subscripting or iterators. ( std::wstrings characters are likely larger than a single byte but std::strings always have 1 byte characters )