数字和字符串互相转换

/*数字转换成字符串*/
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
	int num = 12345;
	char str[20];

	sprintf(str, "%d", num);

	cout << str;
}

 

 

 

/*数字转换成字符串*/
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
	int num;
	char str[20] = "12345";

	sscanf(str, "%d", &num);
	cout << sizeof(num) << "" << num;
}
posted @ 2013-03-08 20:26  helloweworld  阅读(182)  评论(0编辑  收藏  举报