[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
memchr()                 Find Character in Buffer

 #include   <memory.h>                   Required for declarations only
 #include   <string.h>                   Use either string.h or memory.h

 char       *memchr(buf,ch,cnt);
 char       *buf;                        Pointer to buffer
 int        ch;                          Character to copy
 unsigned   cnt;                         Number of characters

    memchr() searches 'buf' for the first occurrence of 'ch'.  The search
    continues until 'ch' is found or 'cnt' bytes have been searched.

    Returns:    If 'ch' is found, a pointer to the location of 'ch' in
                'buf' is returned.  NULL is returned if 'ch' is not found
                within the first 'cnt' bytes of 'buf'.

      Notes:    Buffers are arrays of characters and are usually not
                terminated with a null character ('\0').  The
                buffer-manipulation routines always have a length or
                count argument.

  -------------------------------- Example ---------------------------------

    The following statement finds the first occurrence of 'z' in 'buff'.

         #include <memory.h>

         char buff[100];
         char *bufptr;

         main()
         {
             bufptr = memchr(buffr,'z',100);
         }

See Also: memccpy() memcmp() memcpy() memset()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson