maxishell
Implementation of a shell for Linux-like systems
Loading...
Searching...
No Matches
ft_memcmp.c
Go to the documentation of this file.
1
/* ************************************************************************** */
2
/* */
3
/* ::: :::::::: */
4
/* ft_memcmp.c :+: :+: :+: */
5
/* +:+ +:+ +:+ */
6
/* By: rmikhayl <rmikhayl@student.42london.c +#+ +:+ +#+ */
7
/* +#+#+#+#+#+ +#+ */
8
/* Created: 2023/12/17 17:25:26 by rmikhayl #+# #+# */
9
/* Updated: 2023/12/17 17:25:26 by rmikhayl ### ########.fr */
10
/* */
11
/* ************************************************************************** */
12
13
#include "
libft.h
"
14
15
/* *************************** ft_memcmp ************************************ */
16
/* Compares the first 'n' bytes of two memory blocks 's1' and 's2'. */
17
/* Returns a value indicating their relative order, 0 if identical. */
18
/* */
19
/* In layman's terms: It checks which set of data and if they're different, */
20
/* returns a comparison result. */
21
/* ************************************************************************** */
22
23
int
ft_memcmp
(
const
void
*s1,
const
void
*s2,
size_t
n)
24
{
25
const
unsigned
char
*st1;
26
const
unsigned
char
*st2;
27
28
st1 = s1;
29
st2 = s2;
30
while
(n--)
31
{
32
if
(*st1 != *st2)
33
return
(*st1 - *st2);
34
st1++;
35
st2++;
36
}
37
return
(0);
38
}
ft_memcmp
int ft_memcmp(const void *s1, const void *s2, size_t n)
Definition
ft_memcmp.c:23
libft.h
lib
libft
src
ft_memcmp.c
Generated by
1.9.8