1 개념[ | ]
- C언어 memcpy()
- "memory copy"
- 지정한 크기 만큼의 메모리 영역 복사
2 문법[ | ]
헤더
C
Copy
#include <string.h>
정의
C
Copy
void *memcpy(void *dest, const void *src, size_t n);
3 예시[ | ]
- int형의 배열 src배열을 dst배열로 복사
C
Copy
#include <stdio.h>
#include <string.h>
#define ARR_SIZE 6
void printArray(int *arr, int n) {
int i;
for (i = 0; i < n; i++) printf("%d ", arr[i]);
printf("\n");
}
int main() {
const int src[ARR_SIZE] = {0, 1, 2, 3, 4, 5};
int dst[ARR_SIZE];
memcpy(dst, src, sizeof(src));
printArray(dst, ARR_SIZE);
return 0;
}
Loading
4 같이 보기[ | ]
편집자 John Jeong Jmnote Jmnote bot
로그인하시면 댓글을 쓸 수 있습니다.