首页 > 代码库 > c++中将输入的数字以字符(串)形式输出

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

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++中将输入的数字以字符(串)形式输出