-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memset.c
45 lines (38 loc) · 1.36 KB
/
ft_memset.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memset.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mcosta-d <mcosta-d@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/16 20:00:58 by mcosta-d #+# #+# */
/* Updated: 2023/04/17 12:36:01 by mcosta-d ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memset(void *ptr, int c, size_t n)
{
unsigned char *p;
size_t i;
p = ptr;
i = 0;
while (i < n)
{
p[i] = (unsigned char)c;
i++;
}
return (ptr);
}
/*
#include<stdio.h>
#include<string.h>
int main()
{
char str[20] = "Hello, world!";
char *str2 = ft_memset(str, '*', 5);
printf("Using ft_memset: %s\n", str2);
char str3[20] = "Hello, world!";
char *str4 = memset(str3, '*', 5);
printf("Using memset: %s\n", str4);
return (0);
} */