Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C - <b>memchr() find character in buffer</b> http://www.X-Hacker.org [<<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()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson