[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
STRPOSI
. Summary
strposi(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.
strposi is a case insensitive version of the above.
. 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:
strpos
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson