fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4.  
  5. int ft_strncmp(const char *s1, const char *s2, long n)
  6. {
  7. if (!n--)
  8. return (0);
  9. while (n-- && *s1 == *s2 && *(s1++) && *(s2++))
  10. ;
  11. return ((unsigned char *)(s1 - 1) - (unsigned char *)(s2 - 1));
  12. }
  13.  
  14.  
  15. int main(int ac, char **av)
  16. {
  17. if (ac != 4)
  18. return (0);
  19. printf("ft_strncmp: %d\n", ft_strncmp(av[1], av[2], atoi(av[3])));
  20. printf("strncmp: %d\n", strncmp(av[1], av[2], atoi(av[3])));
  21. return (0);
  22. }
  23.  
Success #stdin #stdout 0.01s 5520KB
stdin
teste teste 42
stdout
Standard output is empty