|
|
coherent
strstr() String Function strstr()
Find one string within another
#include <string.h>
cchhaarr *ssttrrssttrr(_s_t_r_i_n_g_1, _s_t_r_i_n_g_2);
cchhaarr *_s_t_r_i_n_g_1, *_s_t_r_i_n_g_2;
strstr looks for string2 within string1. The terminating null
character is not considered part of string2.
strstr returns a pointer to where string2 begins within string1,
or NULL if string2 does not occur within string1.
For example,
char *string1 = "Hello, world";
char *string2 = "world";
strstr(string1, string2);
returns ssttrriinngg11 plus seven, which points to the beginning of
wwoorrlldd within HHeelllloo, wwoorrlldd. On the other hand,
char *string1 = "Hello, world";
char *string2 = "worlds";
strstr(string1, string2);
returns NULL because wwoorrllddss does not occur within HHeelllloo, wwoorrlldd.
***** See Also *****
string functions, string.h
COHERENT Lexicon Page 1
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.