I am trying to use the atoi
function in order to obtain conversion from string
to int
. The thing is that I have a string array which contains both integers and string values.
From what I've read, in order to get the error code from it, the function must return 0 :
string s = "ssss";
int i = atoi(s.c_str())
if (i == 0)
cout<<"error"<<endl;
end;
How should I proceed if my string value is 0
?
Another issue is with this string : string s = "001_01_01_041_00.png"
. The atoi
function returns the value 1
. Shouldn't it return 0
. Why does it return 1
?