Exception for n==0
This commit is contained in:
parent
e6d089ba42
commit
05cf4aa285
|
@ -6,12 +6,14 @@
|
||||||
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2023/03/24 02:01:33 by tischmid #+# #+# */
|
/* Created: 2023/03/24 02:01:33 by tischmid #+# #+# */
|
||||||
/* Updated: 2023/03/28 05:02:15 by tischmid ### ########.fr */
|
/* Updated: 2023/03/28 18:54:54 by tischmid ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
int ft_strncmp(char *s1, char *s2, unsigned int n)
|
int ft_strncmp(char *s1, char *s2, unsigned int n)
|
||||||
{
|
{
|
||||||
|
if (!n)
|
||||||
|
return (1);
|
||||||
while (*s1 && *s2 && *s1 == *s2 && --n)
|
while (*s1 && *s2 && *s1 == *s2 && --n)
|
||||||
{
|
{
|
||||||
++s1;
|
++s1;
|
||||||
|
@ -24,7 +26,7 @@ int ft_strncmp(char *s1, char *s2, unsigned int n)
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#define STR1 "abd"
|
#define STR1 "abd"
|
||||||
#define STR2 "abc"
|
#define STR2 "abc"
|
||||||
#define LENGTH 3
|
#define LENGTH 0
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue