Byte-wise memory functions for C++ macros. More...
| void * | memcpy(void *dst, void *src, int n) |
| void * | memmove(void *dst, void *src, int n) |
| void * | memset(void *dst, int c, int n) |
| int | memcmp(void *a, void *b, int n) |
Byte-wise memory functions for C++ macros. Load with #include
Do not write #include
These four functions work on raw bytes, not on “C strings with a terminating zero” in the usual library sense. strcpy and strcat are not bound — concatenate with string (a = a + b).
memcmp on two LayoutEditor strings compares their UTF-8 bytes.
memcpy / memmove / memset need a real memory address (void pointer). That is an advanced topic. For comparing text, use memcmp or string operators (==).
#include <string.h>
int main(){
if (memcmp("abc", "abc", 3) != 0) return 1;
if (memcmp("abc", "abd", 3) == 0) return 1;
cout("memcmp ok\n");
}
Copies n bytes from src to dst. The two regions must not overlap. If they might overlap, use memmove.
Takes dst, destination address, src, source address, and n (int), number of bytes. If n ≤ 0, nothing is copied.
Returns: dst (the same pointer you passed in). If dst or src is empty, returns dst without copying.
Copies n bytes from src to dst. Overlap is allowed (the function copies in a safe order).
Takes dst, destination address, src, source address, and n (int), number of bytes.
Returns: dst.
Fills n bytes at dst with the byte value c (only the lowest 8 bits of c are used). memset(p, 0, n) is a common way to zero memory.
Takes dst, destination address, c (int), byte value (0 … 255), and n (int), number of bytes.
Returns: dst.
Compares n bytes at a with n bytes at b. On two string values this compares the text byte by byte.
Takes a, first block or string, b, second block or string, and n (int), how many bytes to compare. If n ≤ 0, the result is 0.
Returns: int
memcmp("abc", "abd", 3) is not 0. memcmp("abc", "abc", 3) is 0.
Python: compare str / bytes with == and slices. This include is for C++ macros only.