feat: add ft_memset function

This commit is contained in:
2025-09-30 19:28:10 +02:00
parent afc50a3718
commit 738c3edf62
2 changed files with 24 additions and 0 deletions

16
ft_memset.c Normal file
View File

@@ -0,0 +1,16 @@
#include "libft.h"
void *ft_memset(void *b, int c, size_t len)
{
char *tmp;
size_t i;
tmp = (char *)b;
i = 0;
while (i < len)
{
tmp[i] = (char)c;
i++;
}
return (b);
}

View File

@@ -1,6 +1,7 @@
#ifndef LIBFT_A
#define LIBFT_A
#include <stddef.h>
# include <stdlib.h>
/*
@@ -47,4 +48,11 @@ int ft_isprint(int c);
*/
size_t ft_strlen(const char *s);
/*
The ft_memset() function writes len
bytes of value c (converted to an
unsigned char) to the string b.
*/
void *ft_memset(void *b, int c, size_t len);
#endif