-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathft_memset.c
47 lines (43 loc) · 1.71 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memset.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cjackows <cjackows@student.42wolfsburg. +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/06/08 22:36:41 by cjackows #+# #+# */
/* Updated: 2022/06/21 18:26:50 by cjackows ### ########.fr */
/* */
/* ************************************************************************** */
#include "../inc/libft.h"
/**
* @brief Function is used to fill a block of memory with given/particular
* value. It is used when you want to fill all or some of the blocks of the
* memory with a particular value. Function writes 'len' bytes of value 'c'
* (converted to an unsigned char) to the string b.
* @param str where the character gets copied too
* @param c the character that gets copied to str
gets convertet to ASCII (int 0 = char 48)
* @param len how many characters gets copied to str
* @return void* str
*/
void *ft_memset(void *b, int c, size_t len)
{
size_t i;
unsigned char *temp;
i = 0;
temp = (unsigned char *)b;
while (len > i)
{
temp[i] = c;
i++;
}
return (b);
}
// int main(void)
// {
// unsigned char str[] = "Hello Wold!";
// ft_memset (str, 'a', 10);
// printf ("str: %s\n", str);
// return (0);
// }