Namespaces
Variants
Views
Actions

strchr

From cppreference.com
< c‎ | string‎ | byte
Revision as of 21:00, 5 April 2013 by 60.50.240.65 (Talk)

Template:ddcl list begin <tr class="t-dsc-header">

<td>
Defined in header <string.h>
</td>

<td></td> <td></td> <tr class="t-dcl ">

<td class="t-dcl-nopad">
char *strchr( const char *str, int ch );
</td>

<td class="t-dcl-nopad"> </td> <td class="t-dcl-nopad"> </td> </tr> Template:ddcl list end

Finds the first occurrence of the character ch in the byte string pointed to by str.

Contents

Parameters

str - pointer to the null-terminated byte string to be analyzed
ch - character to search for

Return value

Pointer to the found character in str, or NULL if no such character is found.

Example

char str[50] = "Hello World";
char *ptr = strchr(str, 'W');
printf("%u", ptr);

Output:

Memory of first occurrence 'W' character in str string.

See also

Template:c/string/byte/dcl list strrchrTemplate:c/string/byte/dcl list strpbrk