memchr

Locates the first occurrence of the specified character (function or macro)

Local Servers:nonblocking
Remote Servers:N/A
Classification:ANSI
Service:Memory Manipulation

Syntax

  #include <string.h>  
   
  void *memchr  (  
     const void   *buf,   
     int           ch,   
     size_t        length);
  

Parameters

buf
(IN) Points to the object to be searched.
ch
(IN) Specifies the character to be located.
length
(IN) Specifies the number of bytes to search.

Return Values

memchr returns a pointer to the located character or NULL if the character does not occur in the object.

Remarks

The memchr function or macro locates the first occurrence of ch (converted to an unsigned char) in the first length characters of the object pointed to by buf.

See Also

memcmp, memcpy, memset

Example

  #include <string.h>  
  #include <stdio.h> 
    
  main ()  
  {  
     char   *where;  
     char    buffer[80];  
     where = memchr (buffer, ’x’, 6);  
     if (where == NULL)  
     {  
        printf ("’x’ not found\n");  
     }  
  }