std::istrstream::istrstream
Min standard notice:
Constructs new std::istrstream and its underlying std::strstreambuf.
# Declarations
explicit istrstream( const char* s );
(deprecated in C++98) (removed in C++26)
explicit istrstream( char* s );
(deprecated in C++98) (removed in C++26)
istrstream( const char* s, std::streamsize n );
(deprecated in C++98) (removed in C++26)
istrstream( char* s, std::streamsize n );
(deprecated in C++98) (removed in C++26)
# Parameters
s: C-string or char array to use as the contents of the streamn: size of the array
# Example
#include <iostream>
#include <strstream>
int main()
{
std::istrstream s1("1 2 3"); // string literal
int n1, n2, n3;
if (s1 >> n1 >> n2 >> n3)
std::cout << n1 << ", " << n2 << ", " << n3 << '\n';
char arr[] = {'4', ' ', '5', ' ', '6'};
std::istrstream s2(arr, sizeof arr);
if (s2 >> n1 >> n2 >> n3)
std::cout << n1 << ", " << n2 << ", " << n3 << '\n';
}