Getting Started -> Use (C ++ Library) OstringStream Output (Format)

zhaozj2021-02-17  53

Original collection

// AWZZZ @ 2002

// Getting Started -> Using (C ) OSTRINGSTREAM Output (Format)

// Apo-> using ostringstream.

// Accident Project of Using OstringStream. (C iostream LIBRARY)

/ *

Reference: http://www.cplusplus.com/ref/iostream/ostringstream/

Description

Ostringstream Class Provides An Interface To Manipulate Strings As IF

They were output streams.

The Objects of this Class Mantain Internal a Pointer to A Stringbuf

Object what can be obtained / modified by calling member rdbuf. this

Streambuf-deerived Object Stores a sequence of characters (string) That

Can Be Obtained / Modified by Calling MEMBER STR.

* /

// Use (C library) ostringstream output (format)

// Simple Example

#include

#include

#include

Using namespace std;

Void test ()

{

// ostringstream OSS;

//oss.str ("ABC ");

Ostringstream OSS ("ABC");

Cout << oss.str () << Endl;

OSS << 8 << endl;

OSS << 3.14 << ENDL;

OSS << "OK." << Endl;

Cout << oss.str () << Endl;

OSS << 8 << "

<< 3.14 << "

<< "OK." << endl;

Cout << oss.str () << Endl;

}

Int main (int Argc, char * argv [])

{

Test ();

Return 0;

}

转载请注明原文地址:https://www.9cbs.com/read-28687.html

New Post(0)