Vitamin4eg

Untitled

Oct 22nd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. int ft_strncmp(char *s1, char *s2, unsigned int n)
  2. {
  3. unsigned int i;
  4.  
  5. i = 0;
  6. while (s1[i] != '\0' && s2[i] != '\0' && i < n)
  7. {
  8. if (s1[i] != s2[i])
  9. return (s1[i] - s2[i]);
  10. i++;
  11. }
  12. if (i < n && ((s1[i] == '\0' && s2[i] != '\0') ||
  13. (s2[i] == '\0' && s1[i] != '\0')))
  14. return (s1[i] - s2[i]);
  15. return (0);
  16. }
Add Comment
Please, Sign In to add comment