GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::istrstream::istrstream(3) C++ Standard Libary std::istrstream::istrstream(3)

std::istrstream::istrstream - std::istrstream::istrstream


explicit istrstream(const char* s); (1)
explicit istrstream(char* s); (2)
istrstream(const char* s, std::streamsize n); (3)
istrstream(char* s, std::streamsize n); (4)


Constructs new istrstream and its underlying std::strstreambuf.


1,2) Constructs the underlying std::strstreambuf by calling strstreambuf(s,0) and
initializes the base class with the address of the strstreambuf. The behavior is
undefined if s is not pointing at an element of a null-terminated array.
3,4) Constructs the underlying std::strstreambuf by calling strstreambuf(s,n) and
initializes the base class with the address of the strstreambuf. The behavior is
undefined if s is not pointing at an element of an array whose length is at least n
elements.


s - C-string or char array to use as the contents of the stream
n - size of the array

// Run this code


#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';
}


1, 2, 3
4, 5, 6


constructor constructs a strstreambuf object
(public member function of std::strstreambuf)
constructor constructs an strstream, optionally allocating the buffer
(public member function of std::ostrstream)
constructor constructs an strstream, optionally allocating the buffer
(public member function of std::strstream)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.