invalid conversion from ‘const char*’ to ‘char’

C++ —用sstream把int转成string类型的方法

Author posted @ 2011年9月15日 08:59 in C/C++ , 4077 阅读


In order to convert an int (or any other numeric type, e.g., float, double, etc.) to string, you can use:

#include <sstream>

int i = 5;
std::string s;
std::stringstream out;
out << i;
s = out.str();


Mike Manilone 说:
2011年9月17日 00:42

string str(itoa(123));
cout << str;

弹琴的企鹅 说:
2012年2月17日 15:57

@Mike Manilone: cool, 谢谢

Liwovosa 说:
2021年5月04日 20:38

Great post, you have pointed out some excellent points, I as well believe this is a very superb website. 123movie

SEO 说:
2022年2月25日 17:22

This is my first visit to your web journal! We are a group of volunteers and new activities in the same specialty. Website gave us helpful data to work.

anonymous 说:
2023年6月24日 23:23

I simply want to tell you that I am new to weblog and definitely liked this blog site. Very likely I’m going to bookmark your blog . You absolutely have wonderful stories. Cheers for sharing with us your blog. Termite Treatment Kissimmee

anonymous 说:
2023年7月31日 03:05

This content is simply exciting and creative. I have been deciding on a institutional move and this has helped me with one aspect. CPA Firm

anonymous 说:
2023年8月11日 05:07

I wrote about a similar issue, I give you the link to my site.  Sky Waters Residences

anonymous 说:
2023年8月11日 05:12

This content is simply exciting and creative. I have been deciding on a institutional move and this has helped me with one aspect. Pinetree Hill

anonymous 说:
2023年8月11日 05:17

The best article I came across a number of years, write something about it on this page.  TMW Maxwell

anonymous 说:
2023年8月11日 05:21

Excellent read, Positive site, where did u come up with the information on this posting?I have read a few of the articles on your website now, and I really like your style. Thanks a million and please keep up the effective work. Cape Royale

anonymous 说:
2023年8月11日 05:25

Very interesting information, worth recommending. However, I recommend this:  Newport Residences

anonymous 说:
2023年8月11日 05:30

For this web site, you will see our account, remember to go through this info. The Lakegarden Residences

anonymous 说:
2023年8月15日 17:29

Such sites are important because they provide a large dose of useful information ...  mobile car detailing

anonymous 说:
2023年8月22日 05:32

Best Drain Cleaning Services Sydney - Looking for a reliable blocked drain plumber in Sydney? We’ve got you covered! Unblock your drains and Blocked Toilet today. Blocked Drains Sydney

anonymous 说:
2023年8月24日 01:46

At Coastal Realty & Property Management, we’ve been managing Hacienda Pinilla Vacation Rentals since 2006, so we thought we’d share some advice for friends looking to visit for the first time.

anonymous 说:
2023年8月31日 23:16

This is very interesting content! I have thoroughly enjoyed reading your points and have come to the conclusion that you are right about many of them. You are great. Douceur sensualité Genève

anonymous 说:
2023年9月10日 23:29

I've proper selected to build a blog, which I hold been deficient to do for a during. Acknowledges for this inform, it's really serviceable! sport betting sites

anonymous 说:
2023年9月20日 18:11

Gives you the best website address       I know there alone you'll find how easy it is. forex broker

anonymous 说:
2023年12月17日 18:15

Your texts on this subject are correct, see how I wrote        this site is really very good. sydney private escorts

登录 *

loading captcha image...
or Ctrl+Enter