Home > Backend Development > C++ > body text

What are memory operations in C language?

王林
Release: 2023-08-26 13:05:08
forward
1150 people have browsed it

What are memory operations in C language?

Library #include contains basic memory operations. Although not strictly string functions, the prototypes of these functions are declared in #include .

These memory operations are as follows:

##void *memchr (void *s, int c, size_t n);In the buffer Search characters in . int memcmp (void *s1, void *s2, size_t n);Compare two buffers. void *memcpy (void *dest, void *src, size_t n);Copy one buffer to another buffer. void *memmove (void *dest, void *src, size_t n);Move a certain number of bytes from one buffer to another . void *memset (void *s, int c, size_t n);Sets all bytes of the buffer to the given characters.
Note that in all cases bytes of memory are copied. The sizeof() function comes in handy again.

memcpy(dest, src, SIZE);Copy characters (bytes)memcpy( idest, isrc, SIZE*sizeof(int));Copy integer array

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

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

For example,

char src[SIZE], dest[SIZE];
int isrc[SIZE], idest[SIZE];
Copy after login

The above is the detailed content of What are memory operations in C language?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template