<string.h> 함수 정리

SuJin·2021년 5월 25일
0

memset

: ptr이 가리키는 메모리를 ptr 배열의 크기만 0xFF 값으로 설정

memset(ptr, 0xFF, sizeof(ptr));

memcpy

: source의 값을 num크기만큼 ptr에 복사

memcpy(ptr, source, num);

strcmp

: text와 "abc"가 같으면 0을 return, 다르면 1을 return
( 0은 거짓, 1은 참)

int tf = strcmp(text, "abc");

strcpy

: text1의 문자열을 text2에 복사

strcpy(text1, text2); 

strstr

:"DE" 로 시작하는 문자열 검색 후 포인터 반환

char text[10] = "ABCDEFG";
char *ptr = strstr(text, "DE");
cout<<ptr<<endl;    // DEFG
profile
Anyone can be anything.

0개의 댓글