text: /* ************************************************************************** */
  /*                                                                            */
  /*                                                        :::      ::::::::   */
  /*   ft_strncmp.c                                       :+:      :+:    :+:   */
  /*                                                    +:+ +:+         +:+     */
  /*   By: nbarreir <nbarreir@student.42sp.org.br>    +#+  +:+       +#+        */
  /*                                                +#+#+#+#+#+   +#+           */
  /*   Created: 2021/02/16 03:09:37 by nbarreir          #+#    #+#             */
  /*   Updated: 2021/04/21 21:10:58 by nbarreir         ###   ########.fr       */
  /*                                                                            */
  /* ************************************************************************** */
  
  #include "libft.h"
  
  int	ft_strncmp(const char *s1, const char *s2, size_t n)
  {
  	size_t	i;
  
  	i = 0;
  	while (i < n && s1[i] != '\0' && s2[i] != '\0')
  	{
  		if (s1[i] != s2[i])
  			return ((unsigned char)(s1[i]) - (unsigned char)(s2[i]));
  		i++;
  	}
  	if (i < n && (s1[i] == '\0' || s2[i] == '\0'))
  	{
  		return ((unsigned char)(s1[i]) - (unsigned char)(s2[i]));
  	}
  	return (0);
  }
  