You are here : cpp0memchr

memchr() - 0

The C library function void *memchr(const void *str, int c, size_t n) searches for the first occurrence of the character c (an unsigned char) in the first n bytes of the string pointed to, by the argument str.


Syntax

void *memchr(const void *str, int c, size_t n)


Example

#include <stdio.h>
#include <string.h>

int main ()
{
   const char str[] = "http://www.tutorialspoint.com";
   const char ch = '.';
   char *ret;

   ret = memchr(str, ch, strlen(str));

   printf("String after |%c| is - |%s|\n", ch, ret);

   return(0);
}


Output / Return Value

String after |.| is - |.tutorialspoint.com|


Limitations


Alternatives / See Also


Reference