본문 바로가기

42Seoul52

ft_itoa itoa? //원 함수 없음 char *ft_itoa(int n); 구현해야할 함수 기능 : Allocates (with malloc(3)) and returns a string representing the integer received as an argument. Negative numbers must be handled. 해석 및 부연설명 : 정수 n을 입력받아 문자열로 반환한다. 음수도 처리되어야하며 할당 실패시엔 NULL을 반환한다. ex) printf("%s\n", ft_itoa(-12345)); 코드 실행 결과 -12345 제대로 문자열로 변환되어 출력된 것을 확인할 수 있다. 의문점 및 생각해볼점 비트연산? 비트 논리연산자 | 우연히 찾아낸 방법이다. '0'은 0011 0000이고, n %.. 2023. 2. 16.
ft_split split? //원 함수 없음 char **ft_split(char const *s, char c); 구현해야할 함수 기능 : Allocates (with malloc(3)) and returns an array of strings obtained by splitting ’s’ using the character ’c’ as a delimiter. The array must be ended by a NULL pointer. 해석 및 부연설명 : 문자열 s를 문자 c를 기준으로 쪼갠 후 새롭게 할당한 문자열 배열에 집어넣어 반환하고, 이때 각 배열은 반드시 NULL로 끝나야한다. ex) char**array; charstr[] = "abcde?fg?hijkl?mnop"; charc = '?'; inti =.. 2023. 2. 16.
ft_strtrim strtrim? //원 함수 없음 char *ft_strtrim(char const *s1, char const *set); 구현해야할 함수 기능 : Allocates (with malloc(3)) and returns a copy of ’s1’ with the characters specified in ’set’ removed from the beginning and the end of the string. 해석 및 부연설명 : 문자열 s1에서 문자열 set에 들어있는 문자들을 앞뒤로 잘라낸 문자열을 새롭게 할당하여 반환한다. 할당 실패시에서는 NULL을 반환한다. ex) charstr[] = "abcaafgdefgff"; charset[] = "abfg"; printf("%s\n", ft_strtri.. 2023. 2. 16.
ft_strjoin strjoin? //원 함수 없음 char *ft_strjoin(char const *s1, char const *s2); 구현해야할 함수 기능 : Allocates (with malloc(3)) and returns a new string, which is the result of the concatenation of ’s1’ and ’s2’. 해석 및 부연설명 : 문자열 s1과 s2를 합한 문자열을 새롭게 할당하여 반환한다. 할당 실패시에서는 NULL을 반환한다. ex) charstr1[] = "abcdefg"; charstr2[] = "hijklmnop"; printf("%s\n", ft_strjoin(str1, str2)); 코드 실행 결과 abcdefghijklmnop str1과 str2가 이어.. 2023. 2. 16.