Repository navigation
Expand file tree
/
Copy pathft_memset.c
More file actions
50 lines (42 loc) · 1.48 KB
/
Copy pathft_memset.c
File metadata and controls
50 lines (42 loc) · 1.48 KB
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
49
50
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_memset.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: smasatak <smasatak@student.42tokyo.jp> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2026/04/23 17:19:08 by smasatak #+# #+# */
/* Updated: 2026/06/18 12:42:39 by smasatak ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void *ft_memset(void *s, int c, size_t n)
{
unsigned char *ptr;
ptr = (unsigned char *)s;
while (n--)
*ptr++ = (unsigned char)c;
return (s);
}
// #include <stdio.h>
// #include <string.h>
// int main(void)
// {
// char *s1;
// char *s2;
// s1 = (char *)malloc(sizeof(char) * 6);
// if (!s1)
// return (0);
// s1 = (char *)ft_memset(s1, 'Z', 5);
// s1[5] = '\0';
// s2 = (char *)malloc(sizeof(char) * 6);
// if (!s2)
// return (0);
// s2 = (char *)memset(s2, 'Z', 5);
// s2[5] = '\0';
// printf("%s\n", s1);
// printf("%s\n", s2);
// free(s1);
// free(s2);
// return (0);
// }