ex01
This commit is contained in:
parent
542478f968
commit
b590433a12
|
@ -0,0 +1,41 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strncmp.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/24 02:01:33 by tischmid #+# #+# */
|
||||
/* Updated: 2023/03/24 02:04:30 by tischmid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
int ft_strncmp(char *s1, char *s2, unsigned int n)
|
||||
{
|
||||
while (*s1 && *s2 && *s1 == *s2 && --n)
|
||||
{
|
||||
++s1;
|
||||
++s2;
|
||||
}
|
||||
return (*s1 - *s2);
|
||||
}
|
||||
|
||||
/* ////
|
||||
#include <stdio.h>
|
||||
#define STR1 "abd"
|
||||
#define STR2 "abc"
|
||||
#define LENGTH 3
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int result;
|
||||
|
||||
printf("'%s' VS '%s' length %d\n", STR1, STR2, LENGTH);
|
||||
result = ft_strncmp(STR1, STR2, LENGTH);
|
||||
if(!result)
|
||||
printf("Strings are the same (0)\n");
|
||||
else
|
||||
printf("Strings are different (offset=%d)\n", result);
|
||||
return (0);
|
||||
}
|
||||
*/ ////
|
Loading…
Reference in New Issue