数字转字符串
- to_string()
#include <string>
to_string(233);
to_string(1.23);
- sprintf() sprintf_s(),用法一样,VS要求使用后缀_s
sprintf(str,"string: %d %X %s %c", a, b, c, d);
- <sstream> <string>
#include <string>
#include <sstream>
stringstream ss;
string str;
sss << 345 << endl;
sss >> str;
字符串转数字
- sscanf(), sscanf_s() 用法一样,VS要求使用后缀_s
char str[] = "123";
sscanf(str,"%d",&a);
-atoi()
d = atoi("123");