#include <string.h> char *strchr(const char *str, int ch);
strchr
searches the null-terminated string str
for the first
occurrence of a specific character ch
, returning a pointer to the first
occurrence, or NULL
if the character does not occur in the string.
NULL
if the character is not found. If
the search character is the null character ('\0'), the
return value addresses the null character at the end of the argument
string.
See the memscntb
function description for information on possible
interactions between the strchr
, memscntb
, or
strscntb
functions.
#include <string.h> #include <stdio.h> main() { char *input; char *nl; input = "abcdefghijknlmnopqrstuvwxyz"; if (nl = strchr(input, 'n')) *nl = '0'; printf("The new line character occurs after %cn", *(nl-1)); }
memchr
, stcpm
, strpbrk
, strrchr
,
strscan
, strstr
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.