Description
An istream is used to convert character sequences into values (such as int or double). Typically, these character sequences originate from a file or terminal keyboard, but there's no requirement that this be true. It's also possible to read input from a string or character vector.
This sample illustrates how to develop your own input stream, tied to a char[] vector. The idea is to use istream for the formatting operations (converting character sequences to values), and then specify a buffer that istream uses to actually read characters from. The buffer will be initialized with the vector specified by the user.
Concept
The sample program declares a buffer type inbuf, derived from basic_streambuf. The constructor for inbuf initializes the buffer structure, using setbuf() and setg(). Input using >> will be read from this buffer.
Special Notes:
See istringstream for a variation on this idea.
Supported
Supported
Supported