16 lines
199 B
C
16 lines
199 B
C
|
|
#include "libft.h"
|
|
|
|
// return length of int
|
|
// eg. 123 -> 3, -123 -> 4
|
|
|
|
size_t ft_nbrlen(int nbr)
|
|
{
|
|
int len;
|
|
|
|
len = (nbr < 0) ? 2 : 1;
|
|
while (nbr /= 10)
|
|
len++;
|
|
|
|
return len;
|
|
} |