The Sstream of STL learning Notes

Source: Internet
Author: User

int turn string

<span style= "FONT-SIZE:18PX;" > #include <cstdio> #include <iostream> #include <sstream>using namespace std; int main () {     int int_s = 12345;    string S;  Declares the string s    stringstream stream;       Statement Stream    stream << int_s;         This operator good image ... Put s input stream    stream >> s;    cout<< "string to numeric result:" <<S<<ENDL;    return 0;} </span>
Once converted, you need to first call the. Clear () method if you want to complete the conversion operation again.


Similarly borrowing >> and << can also complete other data types, such as double/string,float/string, and so on, which is not mentioned here.



Ps:

The <sstream> library has only recently been included in the C + + standard. (Do not confuse <sstream> with the <strstream> that was deleted before the standard was released.) As a result, older compilers, such as GCC2.95, do not support it. If you happen to be using such a compiler and want to use <sstream>, you need to update it first.



The Sstream of STL learning Notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.