#include <stdio.h>

int ft_strncmp(char *s1,char *s2, unsigned int n) {
    while (n--) {
        if (*s1 != *s2) {
            return (*s1 - *s2);
        } else if (*s1 == '\0') {
            return 0;
        }
        s1++;
        s2++;
    }
    return 0;
}
int main() {
    char *str1 = "bonjour";
    char *str2 = "bonsoir";
    char *str3 = "bienvenue";
    char *str4 = "salut";

    printf("%d\n", ft_strncmp(str1, str1, 7));
    printf("%d\n", ft_strncmp(str1, str2, 7));
    printf("%d\n", ft_strncmp(str1, str3, 7));
    printf("%d\n", ft_strncmp(str1, str4, 7));

    return 0;
}

Embed on website

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