strlen 0 if NULL strng

This commit is contained in:
Jack Halford 2016-08-30 00:40:33 +02:00
parent 1252d77e02
commit edb265b68e
2 changed files with 5 additions and 0 deletions

View file

@ -5,6 +5,8 @@ size_t ft_strlen(const char *s)
int i;
i = 0;
if (!s)
return (0);
while (s[i])
i++;
return (i);

View file

@ -7,6 +7,9 @@
# define ABS(x) (((x) < 0) ? -(x) : (x))
# define NEG(x) (((x) < 0) ? 1 : 0)
# define POS(x) (((x) > 0) ? 1 : 0)
# define MIN(a, b) ((a) < (b) ? (a) : (b))
# define MAX(a, b) ((a) > (b) ? (a) : (b))
# define DIST(a, b) (ABS((a) - (b)))
typedef struct s_list
{