-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_memset.c
48 lines (44 loc) · 1.48 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: mbutt <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/02/13 20:53:57 by mbutt #+# #+# */
/* Updated: 2019/02/21 11:30:40 by mbutt ### ########.fr */
/* */
/* ************************************************************************** */
/*
** The C library function void *memset(void *str, int c, size_t len) copies the
** character c (an unsigned char) to the first len characters of the string
** pointed to, by the argument str.
**
** Example:
** memset(str,'$',7)
**
** This is string.h library function
** $$$$$$$ string.h library function
*/
#include "libft.h"
void *ft_memset(void *str, int c, size_t len)
{
char *string;
size_t num;
string = str;
num = 0;
while (num < len)
{
string[num] = c;
num++;
}
return (str);
}
/*
** int main (void)
** {
** char str[] = "Test";
** printf("%s",(ft_memset(str, '#', 2)));
** return(0);
** }
*/