#include <stdio.h>
#include <string.h>
int ft_strncmp(char *s1, char *s2, unsigned int nb)
{
    unsigned int index = 0;
    while (s1[index] != '\0' || s2[index] != '\0' && index < nb)
    {
        if (s1[index] != s2[index])
        {
            return (s1[index] - s2[index]);
        }
        index++;
    }
    return (0);
}
int main() {
    char str1[] = "abc";
    char str2[] = "ab";
    printf("%d\n", ft_strcmp(str1, str2));
    printf("%d\n", strcmp(str1, str2));
    return 0;
}

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: