mirror of
https://github.com/guezoloic/libft.git
synced 2026-01-25 03:34:16 +00:00
feat: add ft_memset function
This commit is contained in:
16
ft_memset.c
Normal file
16
ft_memset.c
Normal 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);
|
||||||
|
}
|
||||||
8
libft.h
8
libft.h
@@ -1,6 +1,7 @@
|
|||||||
#ifndef LIBFT_A
|
#ifndef LIBFT_A
|
||||||
#define LIBFT_A
|
#define LIBFT_A
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -47,4 +48,11 @@ int ft_isprint(int c);
|
|||||||
*/
|
*/
|
||||||
size_t ft_strlen(const char *s);
|
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
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user