-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memset.c
46 lines (40 loc) · 1.62 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
46
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memset.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dolvin17 <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/21 17:03:02 by ghuertas #+# #+# */
/* Updated: 2022/04/25 11:01:30 by dolvin17 ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/* sustituye el buffer de *s con c */
void *ft_memset(void *s, int c, size_t n) //string, valor por el sustituyente y el tamaño de buffer
{
unsigned char *ptr;
ptr = s;
while (n--) //mientras el buffre distinto de cero.
{
*ptr++ = c; //mi puntero igual a c y paso a la siguiente referencia de memoria.
}
return (s); // devuelvo el string modificado
}
/*
#include <string.h>
#include <stdio.h>
int main(void)
{
char buffer1[] = "This is a test";
char buffer2[] = "This is a test";
printf("Original:\n");
printf("Before: %s\n",buffer1);
memset(buffer1, '*', 4);
printf("After: %s\n", buffer1);
printf("Mine: \n");
printf("Before: %s\n", buffer2);
ft_memset(buffer2, '*', 4);
printf("After: %s\n", buffer2);
return (0);
}*/