-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strlen.c
57 lines (51 loc) · 2.24 KB
/
ft_strlen.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlen.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: edetoh <edetoh@student.42lehavre.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/14 12:48:17 by edetoh #+# #+# */
/* Updated: 2024/10/25 11:18:31 by edetoh ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*
* The ft_strlen function calculates the length of a character string.
* It takes a string `str` as argument.
* It returns the number of characters in the string,
excluding the end-of-string character ('\0').
*/
size_t ft_strlen(const char *s)
{
int count;
count = 0;
while (s[count] != '\0')
count++;
return (count);
}
// #include <stdlib.h>
// #include <stdio.h>
// #include <unistd.h>
// #include <assert.h>
// #include <ctype.h>
// #include <string.h>
// int main(int argc, char **argv)
// {
// assert(argc == 2);
// printf("Etape 1 : L'appel a un arguments\n");
// assert(ft_strlen("Hello, World!") == strlen("Hello, World!"));
// printf("Etape 2 : Meme longueur pour 'Hello, World!'\n");
// assert(ft_strlen("") == strlen(""));
// printf("Etape 3 : Meme longueur pour une chaine vide\n");
// assert(ft_strlen("1234567890") == strlen("1234567890"));
// printf("Etape 4 : Meme longueur pour '1234567890'\n");
// assert(ft_strlen("abcdefghijklmno") == strlen("abcdefghijklmno"));
// printf("Etape 5 : Meme longueur pour 'abcdefghijklmno'\n");
// assert(ft_strlen("ABCDEFGHIJKLMNO") == strlen("ABCDEFGHIJKLMNO"));
// printf("Etape 6 : Meme longueur pour 'ABCDEFGHIJKLMNO'\n");
// assert(ft_strlen(argv[1]) == (int)strlen(argv[1]));
// printf("Etape 7 : Meme longueur pour '%s'\n", argv[1]);
// printf("=== Test OK === \n");
// return (0);
// }