ft_bzero()
This commit is contained in:
parent
a60d1e1a87
commit
78e40cde0d
3 changed files with 63 additions and 4 deletions
8
Makefile
8
Makefile
|
|
@ -6,19 +6,19 @@
|
||||||
# By: lalgarra <lalgarra@student.42madrid.com> +#+ +:+ +#+ #
|
# By: lalgarra <lalgarra@student.42madrid.com> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2025/10/03 18:03:12 by lalgarra #+# #+# #
|
# Created: 2025/10/03 18:03:12 by lalgarra #+# #+# #
|
||||||
# Updated: 2025/10/04 13:04:25 by lalgarra ### ########.fr #
|
# Updated: 2025/10/04 16:35:10 by lalgarra ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
# Location of your libft.a; it must already exist
|
# Location of your libft.a; it must already exist
|
||||||
LIBDIR = ../repo_libft_algarra
|
#LIBDIR = ../repo_libft_algarra
|
||||||
#LIBDIR = ../repo_algarra
|
LIBDIR = ../vogsphere_repo
|
||||||
|
|
||||||
CFLAGS += -Wall -Wextra -Werror -g3 -iquote $(LIBDIR)
|
CFLAGS += -Wall -Wextra -Werror -g3 -iquote $(LIBDIR)
|
||||||
|
|
||||||
TESTS := ft_isalpha_test ft_isdigit_test ft_isalnum_test ft_isascii_test \
|
TESTS := ft_isalpha_test ft_isdigit_test ft_isalnum_test ft_isascii_test \
|
||||||
ft_isprint_test ft_toupper_test ft_tolower_test ft_strlen_test \
|
ft_isprint_test ft_toupper_test ft_tolower_test ft_strlen_test \
|
||||||
ft_memset_test
|
ft_memset_test ft_bzero_test
|
||||||
|
|
||||||
%_test : %_test.c
|
%_test : %_test.c
|
||||||
$(CC) $(CFLAGS) $*_test.c -L$(LIBDIR) -lft -o $*_test
|
$(CC) $(CFLAGS) $*_test.c -L$(LIBDIR) -lft -o $*_test
|
||||||
|
|
|
||||||
5
ft_bzero_expected.output
Normal file
5
ft_bzero_expected.output
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
buff: "Iorem ipsum dolor", n=0; after call: buff: "Iorem ipsum dolor", n=0;
|
||||||
|
buff: "Iorem ipsum dolor", n=3; after call: buff: "", n=3;
|
||||||
|
buff: "Iorem ipsum dolor", n=3; after call: buff: "", n=3;
|
||||||
|
buff: "Iorem ipsum dolor", n=16; after call: buff: "", n=16;
|
||||||
|
buff: "Iorem ipsum dolor", n=17; after call: buff: "", n=17;
|
||||||
54
ft_bzero_test.c
Normal file
54
ft_bzero_test.c
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_bzero_test.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: lalgarra <lalgarra@student.42madrid.com> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2025/10/03 18:27:44 by lalgarra #+# #+# */
|
||||||
|
/* Updated: 2025/10/04 16:40:19 by lalgarra ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
void do_test(const char *buff, size_t n)
|
||||||
|
{
|
||||||
|
size_t idx;
|
||||||
|
char c1;
|
||||||
|
|
||||||
|
printf("buff: \"%s\", n=%lu;", buff, n);
|
||||||
|
c1 = '\0';
|
||||||
|
ft_bzero((void *)buff, n);
|
||||||
|
printf(" after call: buff: \"%s\", n=%lu;", buff, n);
|
||||||
|
idx = 0;
|
||||||
|
while (idx < n)
|
||||||
|
{
|
||||||
|
if (*(buff + idx) != c1)
|
||||||
|
{
|
||||||
|
printf(" pos. %lu not set!!", idx);
|
||||||
|
idx = n;
|
||||||
|
}
|
||||||
|
idx++;
|
||||||
|
}
|
||||||
|
printf("\r\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
char buff[18];
|
||||||
|
|
||||||
|
strcpy(buff, "");
|
||||||
|
strcpy(buff, "Iorem ipsum dolor");
|
||||||
|
do_test(buff, 0);
|
||||||
|
do_test(buff, 3);
|
||||||
|
strcpy(buff, "Iorem ipsum dolor");
|
||||||
|
do_test(buff, 3);
|
||||||
|
strcpy(buff, "Iorem ipsum dolor");
|
||||||
|
do_test(buff, 16);
|
||||||
|
strcpy(buff, "Iorem ipsum dolor");
|
||||||
|
do_test(buff, 17);
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue