-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memrchr_bonus.c
29 lines (26 loc) · 1.12 KB
/
ft_memrchr_bonus.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memrchr_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: saugustu <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/10/28 20:55:36 by saugustu #+# #+# */
/* Updated: 2020/11/03 21:23:01 by saugustu ### ########.fr */
/* */
/* ************************************************************************** */
#include <stddef.h>
void *ft_memrchr(const void *s, int c, size_t n)
{
unsigned char ch;
unsigned char *tmp;
ch = (unsigned char)c;
tmp = (unsigned char*)s;
while (n)
{
if (*(tmp + n - 1) == ch)
return (tmp + n - 1);
n--;
}
return (NULL);
}