Move your test.
At present, you start the tokenising:
char str[] ="10 input x";
char * pch;
pch = strtok (str," ,.-");
Then you run through each token:
while (pch != NULL)
{
printf ("%s\n",pch);
pch = strtok (NULL, " ,.-");
}
Then you try to check the second one:
if(strcmp( pch++, "input"))
{
cout<<"yes";
}
The problem is that by the time to check, you have run out of tokens completely...
Try this:
char str[] ="10 input x";
char * pch;
pch = strtok (str," ,.-");
int i = 0;
while (pch != NULL)
{
printf ("%s\n",pch);
if((i == 1) && strcmp( pch, "input"))
{
cout<<"yes";
}
pch = strtok (NULL, " ,.-");
i++;
}
That way, you check the second token against your match string while you can still get at it! :laugh: