✅strlen
- calculate the length of a string
- The strlen() function calculates the length of the string pointed
to by s, excluding the terminating null byte `('\0').
💾함수 원형
size_t strlen(const char *s);
💻Parameter
💻Return value
💾함수 구현
size_t ft_strlen(const char* s)
{
size_t i;
i = 0;
while (s[i] != '\0')
i++;
return (i);
}
💾사용 예시
#include <stdio.h>
void main()
{
char str1[20] = "Hello";
char str2[30] = "Worl\0d!!";
printf("str1 len : %d\n", ft_strlen(str1));
printf("str2 len : %d\n", ft_strlen(str2));
return (0);
}