diff options
| author | Charles <sircharlesaze@gmail.com> | 2019-10-21 13:23:11 +0200 |
|---|---|---|
| committer | Charles <sircharlesaze@gmail.com> | 2019-10-21 13:23:11 +0200 |
| commit | 70a7a3a54d4e300c7ec75d18d14d6d6b174c9ee4 (patch) | |
| tree | 2c07e9ae3c37aaf477e4baa6e991b8cac55af3cd /ft_strncmp.c | |
| parent | 2a6b46d026e7ae16af85c4c211fb685f699a5377 (diff) | |
| download | libft-70a7a3a54d4e300c7ec75d18d14d6d6b174c9ee4.tar.gz libft-70a7a3a54d4e300c7ec75d18d14d6d6b174c9ee4.tar.bz2 libft-70a7a3a54d4e300c7ec75d18d14d6d6b174c9ee4.zip | |
fixed strnstr, added protection on specific functions of part1
Diffstat (limited to 'ft_strncmp.c')
| -rw-r--r-- | ft_strncmp.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/ft_strncmp.c b/ft_strncmp.c index 9e5dfcd..e8188d0 100644 --- a/ft_strncmp.c +++ b/ft_strncmp.c @@ -6,7 +6,7 @@ /* By: cacharle <marvin@42.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2019/10/07 10:27:34 by cacharle #+# #+# */ -/* Updated: 2019/10/20 13:15:38 by cacharle ### ########.fr */ +/* Updated: 2019/10/21 11:04:38 by cacharle ### ########.fr */ /* */ /* ************************************************************************** */ @@ -19,5 +19,7 @@ int ft_strncmp(const char *s1, const char *s2, size_t n) i = 0; while (i < n && s1[i] == s2[i] && s1[i] && s2[i]) i++; + if (i == n) + i--; return (((unsigned char*)s1)[i] - ((unsigned char*)s2)[i]); } |
