Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Telix/SALT v3.15 & RS-232, Hayes - <b>strpos</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
  STRPOS

  .  Summary

  strpos(str <string1>, str <substr>, int <start>);

  .  Description

  The strpos function is used to search for one string within another.
  <string1> is scanned for <substr>, starting at the offset (position)
  indicated by <start>. If the sub-string is found, its offset is re-
  turned, otherwise a value of -1 is returned. Note that the first
  character has an offset of 0, not 1 as in some languages.

  strpos is case sensitive.

  .  Return Value

  An integer value as described above.

  .  Example

  str teststr[] = "cat dog cat dog";
  int i = 0, num = 0;

  while (1)           // loop as long as needed
   {
    i = strpos(teststr, "cat", i);
    if (i == -1)
     break;
    i = i + 1;        // make sure we don't find the same one
    num = num + 1;    // increment count
   }

  prints("'cat' was found ");
  printn(num);
  prints(" times.");

See Also: strposi

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson