add arrintchr
This commit is contained in:
4
Makefile
4
Makefile
@@ -118,7 +118,9 @@ SRCS = ft_memset.c \
|
|||||||
ft_smaller.c \
|
ft_smaller.c \
|
||||||
ft_sign.c \
|
ft_sign.c \
|
||||||
ft_sqrt.c \
|
ft_sqrt.c \
|
||||||
ft_free_tab.c
|
ft_free_tab.c \
|
||||||
|
\
|
||||||
|
ft_arrintchr.c
|
||||||
|
|
||||||
|
|
||||||
ODIR = ./builds
|
ODIR = ./builds
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: hulamy <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2019/11/25 14:45:53 by hulamy #+# #+# */
|
/* Created: 2019/11/25 14:45:53 by hulamy #+# #+# */
|
||||||
/* Updated: 2020/02/27 18:06:10 by hulamy ### ########.fr */
|
/* Updated: 2022/03/23 14:22:33 by simplonco ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -113,4 +113,6 @@ int ft_sign(int i);
|
|||||||
int ft_sqrt(int i);
|
int ft_sqrt(int i);
|
||||||
void ft_free_tab(char **tab);
|
void ft_free_tab(char **tab);
|
||||||
|
|
||||||
|
int ft_arrintchr(int * intarr, int comp, size_t size);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
31
srcs/ft_arrintchr.c
Normal file
31
srcs/ft_arrintchr.c
Normal 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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user