[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]


strstr

Search for a character array within another.

Compatibility:

This function is compatible with the following targets:

ANSI

BeOS

EMB/RTOS

Mac OS

Palm OS

Win32


Prototype:
#include <string.h>
char *strstr(const char *s1, const char *s2);
Parameters:

Parameters for this facility are:

s1  
const char *  
The string to search  
s2  
const char *  
The string to search for  

Remarks:

The strstr() function searches the character array pointed to by s1 for the first occurrence of the character array pointed to by s2.

Both s1 and s2 must point to null terminated ('\0') character arrays.

Return:

strstr() returns a pointer to the first occurrence of s2 in s1 and returns a null pointer (NULL) if s2 cannot be found.

See Also:

"memchr"

"strchr"

Example of strstr() usage.:
#include <string.h>
#include <stdio.h>

int main(void)
{
	static char s1[] = "tomato carrot onion";
	static char s2[] = "on";
	puts(strstr(s1, s2));

	return 0;
}

Output:
onion


[ First ]  [ Previous ]  [ Next ]  [ Last ]  [ Manuals ]

Visit the Metrowerks website at: http://www.metrowerks.com
For assistance contact Metrowerks Technical Support at: cw_support@metrowerks.com
Copyright © 2000, Metrowerks Corp. All rights reserved.

Last updated: August 16, 2000