문제
c
Assignment name : ft_strcpy
Expected files : ft_strcpy.c
Allowed functions:
--------------------------------------------------------------------------------
Reproduce the behavior of the function strcpy (man strcpy).
Your function must be declared as follows:
char *ft_strcpy(char *s1, char *s2);
작동 방식
char* strcpy (char* dst, const char* src);
- src에 있는 문자열을 dst로 복사
- src와 dst 모두 미리 크기를 지정해야 함.
c
// < bus error >
// char *src = "";
// char *dst = "";
// strcpy(src, dst);
char src[10] = "asdf";
char dst[11] = "가나다라마바사";
strcpy(src, dst);
구현 방식
- 그냥 문자열을 복사하면 됨.
- NULL을 집어 넣었을 때를 걱정하지 않음.
- 크기 걱정도 할 필요가 없음.