码迷,mamicode.com
首页 > 编程语言 > 详细

c++中将输入的数字以字符(串)形式输出

时间:2014-09-05 10:02:11      阅读:179      评论:0      收藏:0      [点我收藏+]

标签:c++   string   

http://blog.csdn.net/pipisorry/article/details/39076957


#include <iostream>
#include <sstream>
#include <string>
using namespace std;

void main(){
	int i = 65;	
	cout<<char(i)<<endl;					//输出‘A' <=>printf("%c\n", i);


	stringstream ss;
	ss<<i;
	string s;
	ss>>s;
	cout<<s<<endl;						//输出”65“
	
	
	char *c = new char;
	itoa(65, c, 10);
	cout<<c<<endl;						//输出”65“
	//cout<<strcmp(c, "65")<<endl;	
}

from:

http://blog.csdn.net/pipisorry/article/details/39076957

ref:

http://bbs.csdn.net/topics/390401758?page=1#post-394058528


c++中将输入的数字以字符(串)形式输出

标签:c++   string   

原文地址:http://blog.csdn.net/pipisorry/article/details/39076957

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!