我正在尝试使用该atoi函数来获得从stringto的转换int。问题是我有一个包含整数和字符串值的字符串数组。
根据我的阅读,为了从中获取错误代码,该函数必须返回 0 :
string s = "ssss";
int i = atoi(s.c_str())
if (i == 0)
cout<<"error"<<endl;
end;
如果我的字符串值为 ,我应该如何进行0?
另一个问题是这个字符串 : string s = "001_01_01_041_00.png"。该atoi函数返回值1。它不应该返回吗0?为什么会返回1?