-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memset.c
49 lines (42 loc) · 1.49 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
47
48
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memset.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: nmafa <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/09/16 09:41:52 by nmafa #+# #+# */
/* Updated: 2019/09/16 15:22:00 by nmafa ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <string.h>
void *ft_memset(void *b, int c, size_t len)
{
size_t i;
unsigned char *n;/* n is created to hold place for casted version of void b */
i = 0;
n = (unsigned char *)b;/*n is set to the type cast of b*/
if (len <= 0)
return (b);
while (i < len)
{
n[i] = c;
i++;
}
//printf("n: %s , b: %s\n", (char *)n, (char *)b);
return (b);
}
int main()
{
printf("get's here/n");
char *str;
char st[17] = "This is a string";
//unsigned char *n;
str = st;
//n = (unsigned char *)str;
str = ft_memset((void *)str, '*', 2);
//str[0] = 'h';
printf("%s\n", str);
return (0);
}