View difference between Paste ID: mvQtVwHM and 7jMC4TuD
SHOW: | | - or go back to the newest paste.
1-
int strncmp(char *s1, char *s2, int n)
1+
/*
2
** my_strncmp.c for J06 in /home/viller_m/rendu/Piscine_C_J06
3-
int i;
3+
**
4
** Made by mickael villers
5-
i = 0;
5+
** Login   <[email protected]>
6
**
7-
while (s1[i] && s2[i] && i < n)
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-
if (s1[i] != s2[i])
9+
*/
10
11-
return s1[i] - s2[i];
11+
int	my_strncmp(char *s1, char *s2, int n)
12-
}
12+
13-
}
13+
  int i;
14-
return (0);
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
}