aboutsummaryrefslogtreecommitdiff
path: root/ft_strcount.c
blob: 87ead2950108905fef833b8e26b3461fcc904b91 (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: 2020/01/15 14:45:33 by cacharle          #+#    #+#             */
/*   Updated: 2020/01/16 07:45:32 by cacharle         ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

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

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