mirror of
https://github.com/guezoloic/libft.git
synced 2026-01-25 06:34:14 +00:00
feat(ft_memcmp): add ft_memcmp function
This commit is contained in:
20
ft_memcmp.c
20
ft_memcmp.c
@@ -1,10 +1,16 @@
|
|||||||
#include "libft.h"
|
#include "libft.h"
|
||||||
|
|
||||||
// int ft_memcmp(const void *s1, const void *s2, size_t n)
|
int ft_memcmp(const void *s1, const void *s2, size_t n)
|
||||||
// {
|
{
|
||||||
// const unsigned char *s1_ptr;
|
char *c1;
|
||||||
// const unsigned char *s2_ptr;
|
char *c2;
|
||||||
// size_t i;
|
int i;
|
||||||
|
|
||||||
// while ()
|
c1 = (char *)s1;
|
||||||
// }
|
c2 = (char *)s2;
|
||||||
|
i = 0;
|
||||||
|
while (i < n && c1[i] == c2[i])
|
||||||
|
i++;
|
||||||
|
if (i == n) return (0);
|
||||||
|
return (c1[i] - c2[i]);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user