add arrintchr

This commit is contained in:
hugogogo
2022-03-23 14:26:11 +01:00
parent d622367cfd
commit 39b3f2bc4e
3 changed files with 37 additions and 2 deletions

31
srcs/ft_arrintchr.c Normal file
View File

@@ -0,0 +1,31 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_arrintchr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: simplonco <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/23 14:25:28 by simplonco #+# #+# */
/* Updated: 2022/03/23 14:25:37 by simplonco ### ########.fr */
/* */
/* ************************************************************************** */
/*
* search through an arr of int if it contains the int comp
* return 0 if found, 1 otherwise
*/
#include "libft.h"
int ft_arrintchr(int * intarr, int comp, size_t size)
{
size_t i;
if (!intarr)
return 1;
i = -1;
while (++i < size)
if (intarr[i] == comp)
return 0;
return 1;
}