String Stream Operators [C++ Reference]
Keywords: io,sstream,operators
Date: 2008-10-14T15:42:03-0700

[[String Stream Operators]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- cz
- de
- es
- fr
- it
- jp
- nl
- pl
- ro
- ru
- sk
- tr
- tw

## String Stream Operators

Syntax:

        #include <sstream>
        operator<<
        operator>>

Like C++_I/O_Streams, the simplest way to use string streams is to take advantage of the overloaded « and » operators. The « operator inserts data into the stream. For example:

        stream1 << "hello" << i;

This example inserts the string “hello” and the variable i into stream1. In contrast, the » operator extracts data out of a string stream:

        stream1 >> i;

This code reads a value from stream1 and assigns the variable i that value.

Related Topics: C++ I/O Streams

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •