strdub()
함수는 문자열 s1을 복사하기 위한 충분한 메모리를 할당후 복사를 한 다음 그 포인터를 리턴한다.free()
함수의 인수로도 사용할 수있다.strdup(const char *s1);
const char *s1 : 복사할 문자열 포인터
char * 형 데이터로 리턴
char s1[]="hello world";
char *s2;
s2 = strdup(s1);
printf("s1 : %p, strdup : %p, %s\n", s1, s2, s2); // s1 : 0x7ffee980d9ec, strdup : 0x7ff32dc00630, hello world
참고 링크
https://www.freebsd.org/cgi/man.cgi?query=index&sektion=3&apropos=0&manpath=freebsd