更新中......
--------------------------------------------------------------------------------------------------------------------------------------------------------
·字符串转数字
string str=
"1234";
int a=atoi(str.c_str());
// a=1234
备注:
1)atoi函数原型:int atoi(char *str),返回值是int,小心不要溢出
2)函数把从当前开始的字符(必须是数字或者'+','-',否则转化失败,返回0)到第一个不是数字的字符之间的字符串转化为整数
string s1=
"-1234%lalala",s2=
"lalala1234";
int a1=atoi(s1.c_str()),a2=atoi(s2.c_str());
// a1=-1234;a2=0
转载于:https://www.cnblogs.com/MissCold/p/11437944.html
相关资源:JAVA上百实例源码以及开源项目