libft
Loading...
Searching...
No Matches
ft_memcmp.c
Go to the documentation of this file.
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* ft_memcmp.c :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: tspoof <tspoof@student.hive.fi> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2022/10/31 14:45:46 by tspoof #+# #+# */
9/* Updated: 2022/11/30 17:06:29 by tspoof ### ########.fr */
10/* */
11/* ************************************************************************** */
12
13#include "libft.h"
14
15int ft_memcmp(const void *s1, const void *s2, size_t n)
16{
17 size_t i;
18
19 i = 0;
20 while (i < n)
21 {
22 if (((unsigned char *)s1)[i] != ((unsigned char *)s2)[i])
23 {
24 return (((unsigned char *)s1)[i] - ((unsigned char *)s2)[i]);
25 }
26 i++;
27 }
28 return (0);
29}
int ft_memcmp(const void *s1, const void *s2, size_t n)
Memory compare.
Definition ft_memcmp.c:15