strlen 0 if NULL strng
This commit is contained in:
parent
1252d77e02
commit
edb265b68e
2 changed files with 5 additions and 0 deletions
|
|
@ -5,6 +5,8 @@ size_t ft_strlen(const char *s)
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
|
if (!s)
|
||||||
|
return (0);
|
||||||
while (s[i])
|
while (s[i])
|
||||||
i++;
|
i++;
|
||||||
return (i);
|
return (i);
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,9 @@
|
||||||
# define ABS(x) (((x) < 0) ? -(x) : (x))
|
# define ABS(x) (((x) < 0) ? -(x) : (x))
|
||||||
# define NEG(x) (((x) < 0) ? 1 : 0)
|
# define NEG(x) (((x) < 0) ? 1 : 0)
|
||||||
# define POS(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
|
typedef struct s_list
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue