String Stream Operators

Syntax:

    #include 
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

arrow
arrow
    全站熱搜

    和風信使 發表在 痞客邦 留言(0) 人氣()