piscine-c03/ex00/ft_strcmp.c

41 lines
1.3 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/17 18:25:06 by tischmid #+# #+# */
/* Updated: 2023/03/28 18:55:35 by tischmid ### ########.fr */
/* */
/* ************************************************************************** */
int ft_strcmp(char *s1, char *s2)
{
while (*s1 && *s2 && *s1 == *s2)
{
++s1;
++s2;
}
return (*s1 - *s2);
}
/* ////
#include <stdio.h>
#define STR1 "hellb"
#define STR2 "hello"
int main(void)
{
int result;
printf("'%s' VS '%s'\n", STR1, STR2);
result = ft_strcmp(STR1, STR2);
if(!result)
printf("Strings are the same (0)\n");
else
printf("Strings are different (offset=%d)\n", result);
return (0);
}
*/ ////