The string find_first_not_of() and find_first_of() functions return string::npos
if not found, rather than -1.
while (tokencounter < tokenNo)
{
- if ((pos1 == inputLine.npos) || (pos1 == -1) || (pos == -1) )
+ if ( (pos1 == inputLine.npos) || (pos1 == string::npos) || (pos == string::npos) )
return ""; //return an empty string if tokenNo exceeds the No of tokens in the line
inputLine = inputLine.substr(pos1 , MAXLINE);
tokencounter ++;
}
- if (pos1== -1 || pos == -1)
+ if (pos1== string::npos || pos == string::npos)
return "";
else
return inputLine.substr(pos , pos1-pos); // return the desired token