maxishell
Implementation of a shell for Linux-like systems
Loading...
Searching...
No Matches
ft_memchr.c
Go to the documentation of this file.
1
/* ************************************************************************** */
2
/* */
3
/* ::: :::::::: */
4
/* ft_memchr.c :+: :+: :+: */
5
/* +:+ +:+ +:+ */
6
/* By: rmikhayl <rmikhayl@student.42london.c +#+ +:+ +#+ */
7
/* +#+#+#+#+#+ +#+ */
8
/* Created: 2023/12/17 17:25:28 by rmikhayl #+# #+# */
9
/* Updated: 2023/12/17 17:25:28 by rmikhayl ### ########.fr */
10
/* */
11
/* ************************************************************************** */
12
13
#include "
libft.h
"
14
15
/* *************************** ft_memchr ************************************ */
16
/* Searches for the first occurrence of a specific byte in a memory block. */
17
/* Returns a pointer to the found byte if present; otherwise, returns NULL. */
18
/* */
19
/* Parameters: */
20
/* - 's': A pointer to the memory block to search in. */
21
/* - 'c': The byte value to search for. */
22
/* - 'n': The number of bytes to search within the memory block 's'. */
23
/* */
24
/* In layman's terms: It's like looking for a particular symbol or letter */
25
/* in a collection of characters. If it's found, you get a clue; otherwise, */
26
/* you get nothing. */
27
/* ************************************************************************** */
28
29
void
*
ft_memchr
(
const
void
*s,
int
c,
size_t
n)
30
{
31
const
unsigned
char
*st;
32
unsigned
char
ct;
33
34
st = s;
35
ct = (
unsigned
char)c;
36
while
(n--)
37
{
38
if
(*st == ct)
39
return
((
void
*)st);
40
st++;
41
}
42
return
(NULL);
43
}
ft_memchr
void * ft_memchr(const void *s, int c, size_t n)
Definition
ft_memchr.c:29
libft.h
lib
libft
src
ft_memchr.c
Generated by
1.9.8