Linux int to string method

Source: Internet
Author: User

Recently from the Windows Transplant program found that the to_string () function is not available in Linux, on the web to find several methods, feel that the use of StringStream objects to achieve type conversion is better.

You simply add the following to_sting () function to your project, so you don't need to modify your original program. (This is only my transplant project experience, Master Bypass!) )

/** to_string.cpp * Created on:2014 September 11 * author:tursunjan * Linux int to string*/#include<iostream>#include<sstream>using namespacestd;stringTo_string (inta)   {Ostringstream ostr; Ostr<<A; stringAstr =Ostr.str (); //cout << astr <<endl;   returnAstr;}intMain () {inttestnum=Ten; cout<<to_string (Testnum) <<Endl; return 0;}





Linux int to string method

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.