Getting Started -> Use (C ++ Library) IstringStream Enter (Format)

zhaozj2021-02-17  48

Original collection

do not understand

// AWZZZ @ 2002

// Getting Started -> Using (C Library) IstringStream Enter (Format)

// Apo-> using istringstream.

// Accident Project of use IStringStream. (C iostream library)

/ *

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

Description

IstringStream Class Provides An Interface To Manipulate Strings As IF

They were input 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 ) IstringStream input (format)

// Simple Example

#include

#include

#include

Using namespace std;

Void test ()

{

{

// istringstream ISS;

//iss.str (""#123 1.23 aaa, zzz kk, k oo.jj");

IstringStream ISS ("# 123 1.23 aaa, zzz kk, k oo.jj");

Cout << Iss.str () << endl;

CHAR CH;

ISS >> CH;

COUT << CH << endl;

INT I;

ISS >> I;

COUT << i << endl;

Float f;

ISS >> F;

Cout << f << endl;

Char BUF [1024];

ISS >> BUF;

Cout << BUF << Endl;

Iss.ignore (100, ',');

ISS >> BUF;

Cout << BUF << Endl;

}

}

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

{

Test ();

Return 0;

}

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

New Post(0)