#include <stdio.h>
#include <string.h>
//int strcmp(const char *s1, const char *s2);
int ft_strcmp(char *s1, char *s2)
{
int i;
i = 0;
while (s1[i] && s2[i] && (s1[i] == s2[i]))
i++;
return (s1[i] - s2[i]);
}
int main(void)
{
char *firt;
char *second;
firt = "World!";
second = "World!";
printf("%d\n", strcmp(firt, second));
printf("%d\n", ft_strcmp(firt, second));
firt = "World!";
second = "Wor!";
printf("%d\n", strcmp(firt, second));
printf("%d\n", ft_strcmp(firt, second));
firt = "Wor";
second = "World!";
printf("%d\n", strcmp(firt, second));
printf("%d\n", ft_strcmp(firt, second));
return (0);
}
To embed this project on your website, copy the following code and paste it into your website's HTML: