

#include <string.h> void *memchr(const void *ptr, int ch, size_t n);
memchr searches n bytes, beginning at the location pointed to
by ptr, for the first occurrence of ch.
ch, or
NULL if the character cannot be found.
memchr is size_t.
See the memscntb function description for information on possible
interactions between the memchr, memscntb, or
strscntb functions.
#include <string.h>
#include <stdio.h>
#define SIZE 256
main()
{
char area[SIZE];
int offset = 0;
int count = 0;
char *next, *prev;
int i;
/* Every alternate element is assigned zero value. */
for (i = 0; i <= 255; i+=2) {
area[i] = '1';
area[i+1] = '0';
}
prev = area;
for (;;) {
next = memchr(prev, '0' , 256 - offset);
if (!next) break;
++count;
prev = next+1;
offset = (prev - area + 1);
}
printf("%d zero bytes found. n", count);
}
strchr, memscan
Copyright (c) 1998 SAS Institute Inc. Cary, NC, USA. All rights reserved.