C String Library Function memchr

C String Library Function memchr : In string class memchr() function helps us to find a byte within a specific memory block. It takes three parameters memchr(buffer, char, size); and returns pointer to the first occurrence where char is found else it returns NULL.

C String Library Function memchr

#include<stdio.h>
#include<string.h>
int main()
{
   const char *str = "Learn Programming from CodeBlah.com";
   const char ch = 't';
   printf("str = %s\n\n", str);

   printf("Remaining string after '%c' : %s\n", ch, (char *) memchr( str, ch, strlen(str)));

   return 0;
}

Output of Program

str = Learn Programming from CodeBlah.com

Remaining string after ‘t’ : (null)