본문 바로가기

libft36

ft_memcmp memcmp? #include int memcmp(const void *s1, const void *s2, size_t n); Linux manpage description : The memcmp() function returns an integer less than, equal to, or greater than zero if the first n bytes of s1 is found, respectively, to be less than, to match, or be greater than the first n bytes of s2. For a nonzero return value, the sign is determined by the sign of the difference between the f.. 2023. 2. 16.
ft_memchr memchr? #include void *memchr(const void *s, int c, size_t n); Linux manpage description : The memchr() function scans the initial n bytes of the memory area pointed to by s for the first instance of c. Both c and the bytes of the memory area pointed to by s are interpreted as unsigned char. 해석 및 부연설명 : 포인터 s가 가리키는 메모리에서 n바이트만큼 스캔해 c가 가장 처음 나오는 곳의 주소를 반환한다. 이 때 c와 메모리의 값은 unsigned char로 해석된다. 찾지.. 2023. 2. 16.
ft_calloc calloc? #include void *calloc(size_t nmemb, size_t size); Linux manpage description : The calloc() function allocates memory for an array of nmemb elements of size bytes each and returns a pointer to the allocated memory. The memory is set to zero. If nmemb or size is 0, then calloc() returns either NULL, or a unique pointer value that can later be successfully passed to free(). If the multiplic.. 2023. 2. 16.
ft_atoi atoi? #include int atoi(const char *nptr); Linux manpage description : The atoi() function converts the initial portion of the string pointed to by nptr to int. The behavior is the same as strtol(nptr, NULL, 10); except that atoi() does not detect errors. 해석 및 부연설명 : 포인터 nptr이 가리키는 문자열을 int로 변환하여 반환한다. ex) charstr[] = "-1535abcd"; printf("%d\n", atoi(str)); 코드 실행 결과 -1535 '-'부호가 적용되고, int로 표현할 수.. 2023. 2. 16.