c++中的数据类型转换问题,急!!
在一个字符串中,例如string str="1 2 1 5 4 3 7 6 10 9 8";我怎么将字符串str中的10提取出来,并且转化成int类型的!!
2012-05-21 11:14
2012-05-21 11:31
2012-05-21 19:06
程序代码:#include <iostream>
#include <string>
int main()
{
std::string str("1 2 3 4 5 6 7 8 9 10 11");
int a = atoi(&str[18]);
std::cout<<a<<std::endl;
return 0;
}
2012-05-22 21:17
2012-05-22 23:32