beautypg.com

Memchr, Memcmp, Memchr memcmp – Zilog EZ80F916 User Manual

Page 370

background image

UM014423-0607

C Standard Library

ZiLOG Developer Studio II

eZ80Acclaim!

®

User Manual

350

Returns

A pointer to the start (lowest byte address) of the allocated space. If the space cannot be
allocated, or if

size

is zero, the

malloc

function returns a null pointer.

Example

char *buf;
buf=(char *) malloc(40*sizeof(char));
if(buf !=NULL)

/*success*/

else

/*fail*/

memchr

Locates the first occurrence of c (converted to an

unsigned char

) in the initial n charac-

ters of the object pointed to by s.

Synopsis

#include
void *memchr(void *s, int c, size_t n);

Returns

A pointer to the located character or a null pointer if the character does not occur in the
object.

Example

char *p1;
char str[]="COMPASS";
c='p';
p1=memchr(str,c,sizeof(char));

memcmp

Compares the first n characters of the object pointed to by s2 to the object pointed to by s1.

Synopsis

#include
int memcmp(void *s1, void *s2, size_t n);

Returns

An integer greater than, equal to, or less than zero, according as the object pointed to by s1
is greater than, equal to, or less than the object pointed to by s2.

This manual is related to the following products: