想象一下像这样的代码:
vector<string> lsLineNumbers;
lsLineNumbers.push_back("9, 0xbaadf00d, 3, 4");
lsLineNumbers.push_back("0xcoffee99, 4, 7, 1, 3, 5, 0xdeadbeef, 78");
当您查看调试器时,它看起来像字符串数组lsLineNumbers [0] =&#34; 9,0xbaadf00d,3,4&#34;和lsLineNumbers [1] =&#34; 0xcoffee99,4,7,1,3,5,6ddeadbeef,78&#34;
如何提取这些数字字符串,以便我可以进行字符串到整数转换?我可以手动完成,但我确信它有一个功能。我会想象这样的事情......
for (i = 0; i < lsLineNumbers.size(); i++) [
while((str = getstring(lsLineNumbers[0])) != '\0') {
num = _atoi64(str);
cout << num;
}
}