Guardian C Library Calls Reference Manual
Reference to Library Calls
Guardian TNS C Library Calls Reference Manual—128833 3-183
stcpm (supplementary)
Usage Guidelines
•
Note that match_ptr has type pointer to pointer to char. This function returns the
length of the first matching substring; a pointer to it is returned through match_ptr.
•
You can use the backslash (\) as an escape character to match one of the special
characters. If you specify pat_ptr as a string literal, you must use two backslashes.
For example, to search for the string “??” you would specify the string literal:
"\\?\\?"
Similarly, to search for a single backslash (by specifying “\\” as the pattern string)
you would specify the string literal:
"\\\\"
Example
This example scans a string to find the first occurrence of the pattern “FO?T”:
#include <stringh>
int main(void)
{
int length;
char *string;
char *pattern;
char *match;
string = "TANDEM is a FORTUNE 500 company";
pattern = "FO?T"; /* will match "FO", then */
/* any char, then "T" */
length = stcpm(string, pattern, &match);
printf("%d %s\n", length, match);
/* prints "4 FORTUNE 500 company" */
}