Computer >> 컴퓨터 >  >> 프로그램 작성 >> C 프로그래밍

C 언어의 메모리 연산은 무엇입니까?

<시간/>

#include 라이브러리에는 기본 메모리 작업이 포함되어 있습니다. 엄밀히 말하면 문자열 함수는 아니지만 함수는 #include 에서 프로토타입됩니다.

이러한 메모리 작업은 다음과 같습니다 -

void *memchr (void *s, int c, size_t n); 버퍼에서 문자를 검색합니다.
int memcmp(무효 *s1, 무효 *s2, size_t n); 두 버퍼를 비교합니다.
무효 *memcpy(무효 *dest, 무효 *src, size_t n); 한 버퍼를 다른 버퍼에 복사합니다.
무효 *memmove (무효 *dest, 무효 *src, size_t n); 한 버퍼에서 다른 버퍼로 많은 바이트를 이동합니다.
무효 *memset(무효 *s, int c, size_t n); 버퍼의 모든 바이트를 주어진 문자로 설정합니다.

모든 경우에 메모리의 바이트로 복사됩니다. sizeof() 함수가 다시 유용합니다.

memcpy(dest, src, SIZE); 문자(바이트) 복사
memcpy(idest, isrc, SIZE*sizeof(int)); 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];