I do not understand why the following code is returning *end=='\0\'?
bool isValue(const string &token,int &output_value) //czy string jest wartoscia
{
char *end = 0;
errno=0;
output_value = strtol(token.c_str(),&end,10); //converts string to int
if (errno!=0) return false;
return *end=='\0';
}
EDIT: And stupid question but I don’t know why there is
bool isValue(const string &token,int &output_value)
instead of
bool isValue(string &token,int &output_value)
and
bool isValue(string token,int output_value)
The<— thoughterrnopart is probably legacy code. It could have been used at some point, but the code that used it could have been removed, buterrnoforgotten. You’re right, it does nothing and will probably be optimized out.errnowas a local variable (stealth edit?)endisso basically the condition checks whether there were any other characters in the string after the number.