c++常用函数
string s;
cin>>s;
int num=atoi(s.c_str());//将字符串s转化成整数(以ASCII码的形式)。
c_str
c_str是Borland封装的String类中的一个函数,它返回当前字符串的首字符地址。
atoi
函数原型:int atoi(const char *nptr);
atoi (表示 ascii to integer)是把字符串转换成整型数的一个函数,应用在计算机程序和办公软件中。int atoi(const char *nptr) 函数会扫描参数 nptr字符串,会跳过前面的空白字符(例如空格,tab缩进)等。如果 nptr不能转换成 int 或者 nptr为空字符串,那么将返回 0.