atoi string转换为其它数据类型

字符串string转换为其它数据类型

int atoi(const char *nptr);

string str="123456";

temp=str.c_str();

1)短整型(int)
i =  atoi(temp);
2)长整型(long)
l =  atol(temp);
3)浮点(double)
d= atof(s.c_str());

猜你喜欢

转载自www.cnblogs.com/wllwqdeai/p/10003387.html