Memmove, Memset, Memmove memset – Zilog Z8F0130 User Manual

Page 474

Advertising
background image

Appendix B. C Standard Library

UM013037-1212

450

Zilog Developer Studio II – Z8 Encore!
User Manual

Example

char s1[10];

char s2[10] = "COMPASS";

memcpy(s1, s2, 8);

memmove

Moves n characters from the object pointed to by s2 into the object pointed to by s1.

Copying between objects that overlap takes place correctly.

Synopsis

#include <string.h>

void *memmove(void *s1, void *s2, size_t n);

Returns

The value of s1.

Example

char s1[10];

char s2[]="COMPASS";

memmove(s1, s2, 8*sizeof(char));

memset

Copies the value of c (converted to an

unsigned char

) into each of the first n characters

of the object pointed to by s.

Synopsis

#include <string.h>

void *memset(void *s, int c, size_t n);

Returns

The value of s.

Example

char str[20];

char c='a';

memset(str, c, 10*sizeof(char));

Advertising