#include <string.h> char *strstr(const char *str1, const char *str2);
strstr
scans the input string str1
for the first occurrence of
the search string str2
.
strstr
returns a character pointer to the first occurrence of the
search string in the input string. If the search string cannot be found,
strstr
returns NULL
.
#include <string.h> #include <stdio.h> main() { char *text_buffer ="12345-n67-n89"; char *word_break ="-n"; char *hyphen; hyphen = strstr(text_buffer, word_break); printf("The first occurence of "-n" is after the digit %cn", *(hyphen-1)); }
strchr
, stcpm
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.