void main() { char * ss = "9.9"; double a = atof(ss);//将字符串转为浮点数 cout << "a:" << a << endl; int b = atoi(ss);//将字符串转为整数 cout << "b:" << b << endl; char str[256]; _itoa(b, str, 10);//将整数转为字符串,10表示10进制,windows专用,不能跨平台 cout << str << endl; //可跨平台,并且功能更强大 sprintf(str, "%f", a); cout << str << endl; sprintf(str, "%d", b); cout << str << endl; }
atoi、atof、itoa、sprintf作用
猜你喜欢
转载自blog.csdn.net/omodao1/article/details/80628483
今日推荐
周排行