memcpy, memset and memmove
memcpy copies bytes between non overlapping blocks, memmove handles overlap, memset fills memory and memcmp compares blocks.
Example
int a[4] = {1, 2, 3, 4}, b[4];
memcpy(b, a, sizeof a);
memset(a, 0, sizeof a);
printf("%d %d\n", b[3], a[3]);
char s[] = "abcdef";
memmove(s + 2, s, 3);
printf("%s\n", s);
printf("%d\n", memcmp(b, b, sizeof b));Result
4 0 ababcf 0
Exercise
Fill with zeros.
(a, 0, sizeof a)Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.