C语言中的内存操作是什么?

库#include <memory.h> 包含基本的内存操作。虽然不是严格的字符串函数,但函数的原型是在#include <string.h> 中。

这些内存操作如下 -

void *memchr (void *s, int c, size_t n);在缓冲区中搜索字符。
int memcmp (void *s1, void *s2, size_t n);比较两个缓冲区。
void *memcpy (void *dest, void *src, size_t n);将一个缓冲区复制到另一个缓冲区。
void *memmove (void *dest, void *src, size_t n);将多个字节从一个缓冲区移动到另一个缓冲区。
void *memset (void *s, int c, size_t n);将缓冲区的所有字节设置为给定字符。

请注意,在所有情况下都会复制内存字节。该sizeof()功能再次派上用场。

memcpy(dest, src, SIZE);复制字符(字节)
memcpy(idest, isrc, SIZE*sizeof(int));复制整数数组

memmove() behaves in exactly the same way as memcpy() except, that the source and destination locations may overlap.

memcmp() is similar to strcmp() except here, unsigned bytes are compared and returns less than zero if si is less than s2 etc.

例如,

char src[SIZE], dest[SIZE];
int isrc[SIZE], idest[SIZE];