Strstr - Texas Instruments TI-89 Developer's Manual

Graphing calculator
Hide thumbs Also See for TI-89:
Table of Contents

Advertisement

1002

strstr

Declaration:
char * strstr (const char * s1 , const char * s2 )
Category(ies):
Strings
Description:
Searches the string pointed to by s1 for a substring matching the string
pointed to by s2 .
s1 — Character string to search in.
Inputs:
s2 — Character string to search for.
Returns a pointer to the first character of the matching substring in s1 , or a
Outputs:
null pointer if no matching substring is found.
Assumptions:
None
Side Effects:
None
Availability:
All versions of the TI-89 / TI-92 Plus.
TI-89 / TI-92 Plus
Differences:
None
See Also:
strchr, memchr
Example:
BOOL findstr( const char *str1, const char *str2, char *buf )
/* findstr - Find the first instance of string str2 in string str1.
Return TRUE if found str2 in str1 and build message in buf,
else return FALSE.
*/
{
char *ptr;
if( ( ptr = strstr(str1, str2)) == NULL )
return( FALSE );
sprintf( buf, "Found '%s' at position %d in string: %s\n",
str2, (ptr - str1 + 1), str1);
return( TRUE );
}
TI-89 / TI-92 Plus Developer Guide
Appendix A: System Routines — Strings
/* str2 not found in str1 */
Not for Distribution
Beta Version January 26, 2001

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ti-92 plusTi-92 plus

Table of Contents