strchr example in c
strchr function in c programming find the first appearance of the character in the string.
The character in c programming function can be null character (/0) and the ending null char. also include in this string search.
A string argument also contain the null character so that the end of the string can be noticed.
Return value for strchr program in c
strchr function return a pointer if specified character are appears in the given string otherwise it return the NULL.
Example Program for strchr function in c
#include<stdio.h> #include <string.h> int main(void) { char buffer1[SIZE] = "computer program"; char * ptr; int ch = 'p'; ptr = strchr( buffer1, ch ); printf( "The first occurrence of %c in '%s' is '%s'\n", ch, buffer1, ptr ); }
0 comments:
Post a Comment