有一定C++基础的人不难写出字符串到整数的转换代码 如果是初学者,考虑使用atoi函数(包含stdlib.h或者cstdlib函数,事实上,包含iostream就够了) 原型: int atoi(const char *str); 用法: std::string str="789";int num=atoi(str.c_str());std::cout<<num;或者: char str[]="789";int num=atoi(str);std::
← 上一条:在c++中char类型的数组里边装的是数字, 下一条:C++中将char转换为int型 →