54 lines
1.6 KiB
C
54 lines
1.6 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* 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);
|
|
}
|