aboutsummaryrefslogtreecommitdiff
path: root/ft_strcount.c
diff options
context:
space:
mode:
Diffstat (limited to 'ft_strcount.c')
-rw-r--r--ft_strcount.c24
1 files changed, 24 insertions, 0 deletions
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 <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);
+}