tgrekov-fdf
HIVE fdf May 2024
Loading...
Searching...
No Matches
ft_strncmp.c
Go to the documentation of this file.
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* ft_strncmp.c :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: tgrekov <tgrekov@student.hive.fi> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2023/10/24 17:25:34 by tgrekov #+# #+# */
9/* Updated: 2023/11/09 20:52:51 by tgrekov ### ########.fr */
10/* */
11/* ************************************************************************** */
12
20#include "libft.h"
21
33int ft_strncmp(const char *s1, const char *s2, size_t n)
34{
35 size_t i;
36
37 i = 0;
38 while (i < n && (s1[i] || s2[i]))
39 {
40 if (s1[i] != s2[i])
41 return ((unsigned char) s1[i] - (unsigned char) s2[i]);
42 i++;
43 }
44 return (0);
45}
int ft_strncmp(const char *s1, const char *s2, size_t n)
Compare up to n characters of string s1 with string s2.
Definition ft_strncmp.c:33