When strtok is used and it doesn't find the delimiter when strtok is used the FIRST time, it should return a null. But this doesn't seems to be the behavior. Pl refer to this code -
Actually the value is same as the original string - "string to split up". The above code prints -
"result is NOT null"
Re: strtok query
No, it should not. Strtok returns a NULL when no more tokens are found. On the first call it found "string to split up". The return will be a pointer to that token, which happens to be the entire input string.
Do yourself a favor: read the documentations for the things you use.
Do us a favor: learn to use the code tags like a big boy. Quit forcing the task on Shabbir.
|All times are GMT +5.5. The time now is 13:32.|