aboutsummaryrefslogtreecommitdiff
path: root/test_mini/libft/src/str/ft_strcount.c
blob: 87e756df9aeff3d31ec5f7a8e82afef548b72ca6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   ft_strcount.c                                      :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: cacharle <marvin@42.fr>                    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2019/11/15 09:17:48 by cacharle          #+#    #+#             */
/*   Updated: 2019/11/15 09:19:36 by cacharle         ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

int	ft_strcount(char *str, char c)
{
	int	counter;

	if (c == '\0')
		return (1);
	counter = 0;
	while (*str)
		if (*str++ == c)
			counter++;
	return (counter);
}