Working on ft_strlcpy()
This commit is contained in:
parent
95e346c2ee
commit
8065f4722e
3 changed files with 77 additions and 4 deletions
72
ft_strlcpy_test.c
Normal file
72
ft_strlcpy_test.c
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strlcpy_test.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lalgarra <lalgarra@student.42madrid.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/10/05 13:21:43 by lalgarra #+# #+# */
|
||||
/* Updated: 2025/10/05 14:52:21 by lalgarra ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libft.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/*
|
||||
static void do_test3(char *prefix)
|
||||
{
|
||||
int *buff;
|
||||
size_t buflen;
|
||||
size_t size;
|
||||
|
||||
buflen = 5;
|
||||
size = 0;
|
||||
buff = ft_calloc(buflen, size);
|
||||
printf("%ssize= %lu; buff == NULL: %i\n", prefix, size, buff == NULL);
|
||||
free(buff);
|
||||
}
|
||||
|
||||
static void do_test2(char *prefix)
|
||||
{
|
||||
int *buff;
|
||||
size_t buflen;
|
||||
|
||||
buflen = 0;
|
||||
buff = ft_calloc(buflen, sizeof(int));
|
||||
printf("%sbuflen = %lu; buff == NULL: %i\n", prefix, buflen, buff == NULL);
|
||||
free(buff);
|
||||
}
|
||||
*/
|
||||
static void do_test1(char *prefix)
|
||||
{
|
||||
char src[128];
|
||||
char dest[128];
|
||||
int fd;
|
||||
size_t size;
|
||||
size_t res;
|
||||
|
||||
fd = STDOUT_FILENO;
|
||||
size = 10;
|
||||
bzero(dest, size);
|
||||
memcpy(src, "Lorem ipsum dolor sit amet consectetur adipiscing elit.", 56);
|
||||
memset(dest, 'X', size + 2);
|
||||
ft_putstr_fd(prefix, fd);
|
||||
ft_putstr_fd("src:[", fd);
|
||||
ft_putstr_fd(src, fd);
|
||||
ft_putstr_fd("], dest:[", fd);
|
||||
ft_putstr_fd(dest, fd);
|
||||
res = ft_strlcpy(dest, src, size);
|
||||
ft_putstr_fd("], result:[", fd);
|
||||
ft_putnbr_fd((int) res, fd);
|
||||
ft_putstr_fd("], dest:[", fd);
|
||||
ft_putstr_fd(dest, fd);
|
||||
ft_putendl_fd("]", fd);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
do_test1("test 1: ");
|
||||
return (0);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue