Advertisement
villers

Untitled

Oct 7th, 2014
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. ** my_strncmp.c for J06 in /home/viller_m/rendu/Piscine_C_J06
  3. **
  4. ** Made by mickael villers
  5. ** Login   <[email protected]>
  6. **
  7. ** Started on  Mon Oct  6 14:08:02 2014 mickael villers
  8. ** Last update Tue Oct  7 21:25:12 2014 mickael villers
  9. */
  10.  
  11. int my_strncmp(char *s1, char *s2, int n)
  12. {
  13.   int i;
  14.  
  15.   i = 0;
  16.   while (s1[i] && s2[i] && i < n)
  17.     {
  18.       if (s1[i] != s2[i])
  19.     {
  20.       return (s1[i] - s2[i]) < 0 ? -1 : 1;
  21.     }
  22.       i = i + 1;
  23.     }
  24.   return (0);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement