aboutsummaryrefslogtreecommitdiff
path: root/c11/ex03/ft_count_if.c
blob: 1b1c00abb51841b12760fefbe92e0fabbb52df5e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_count_if.c                                      :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: cacharle <charles.cabergs@gmail.com>       +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2019/07/16 21:35:34 by cacharle          #+#    #+#             */
/*   Updated: 2019/07/16 21:36:42 by cacharle         ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

int ft_count_if(char **tab, int length, int(*f)(char*))
{
	int	counter;

	counter = 0;
	while (length-- > 0)
		if ((*f)(*tab++))
			counter++;
	return (counter);
}