Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- DMA
- layouts
- ubuntu
- Shared Folder
- fprintf
- jenkins
- sscanf
- 멀티프로세싱
- sprintf
- usb2.0
- intents
- 소캣
- interrupt context
- 디스크립터
- 환경 변수
- 속도저하
- gparted
- pagefile.sys
- HDR
- activities
- context switch
- 문자형 디바이스 파일
- 젠킨스
- fscanf
- 디스크 축소
- 프레임버퍼
- memcmp
- interrupt handler
- makefile
- context
Archives
- Today
- Total
do{학습}while
c) memcmp() 본문
기능 요약
memcmp 함수는 두 메모리 블록의 시작 주소에서 시작하여 지정된 바이트 수(num 바이트)만큼의 데이터를 비교
헤더파일
#include <string.h> // C++ 에서는 <cstring>
원형
int memcmp(const void* ptr1, const void* ptr2, size_t num);
반환값
주의 사항
예시 코드
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
typedef struct{
int age;
char name[3];
}person;
int main(){
size_t l1,l2;
int result;
person *p1 = (person *)malloc(sizeof(person));
p1->age = 28;
strcpy(p1->name,"dongju");
person *p2 = (person *)malloc(sizeof(person));
p2->age = 28;
strcpy(p2->name,"dongju");
size_t data_size = sizeof(person); // 구조체 내부 데이터의 크기
result = memcmp(p1, p2, data_size);
printf("%d\\n", result);
free(p1);
free(p2);
return 0;
}
'C & C++ > c언어 표준함수' 카테고리의 다른 글
| c) puts() (0) | 2024.05.28 |
|---|---|
| c) fgets() (0) | 2024.05.28 |
| c) sscanf() (0) | 2024.05.27 |
| c) sprintf() (0) | 2024.05.27 |
| c) fscanf() (0) | 2024.05.27 |