From d22609e03717283e85a23587203af1b8b7d2fde2 Mon Sep 17 00:00:00 2001 From: Charles Date: Thu, 16 Jan 2020 10:15:08 +0100 Subject: Added ft_strcount --- ft_strcount.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 ft_strcount.c (limited to 'ft_strcount.c') diff --git a/ft_strcount.c b/ft_strcount.c new file mode 100644 index 0000000..87ead29 --- /dev/null +++ b/ft_strcount.c @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* ft_strcount.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: cacharle +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} -- cgit