Question : strstr


i am interested in finding the word that doesn't occur in strstr ...

is there a function for it.

for example,

 this is a string

and i am looking for the this, is, a , string..

strstr(ptr,' ') would give the index of the start of the empty space but i want the value which is the start of the string but i am looking for value that does not begin with ' '. is there such a function for it.


Answer : strstr

You may want to consider using strcspn.
 -- "Get span of character set in string"

 -- "Returns the length of the initial portion of str1 which consists only of characters that are part of str2."

For example:
   char sentence[] = "this is a string ";
   int pos = strcspn( sentence, " ");
In this case pos will be 4, so you know that sentence[0] through sentence[3] are not blanks. You can then use strncpy with a count of 4 to copy out the first 4 chars into your token buffer (and then add null byte).
Random Solutions  
programming4us programming4us