aboutsummaryrefslogtreecommitdiffstats
path: root/ft_strncmp.c
blob: 2fa10991864f19e07a5fdc7d230346dfb9383783 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include "libft.h"

int
ft_strncmp (const char *s1, const char *s2, size_t n)
{
  while (n--)
    {
      if ((unsigned char)*s1 != (unsigned char)*s2)
        return ((unsigned char)*s1 - (unsigned char)*s2);
      if (*s1 == '\0')
        return (0);
      s1++;
      s2++;
    }
  return (0);
}