-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcounter.c
More file actions
39 lines (37 loc) · 699 Bytes
/
Copy pathcounter.c
File metadata and controls
39 lines (37 loc) · 699 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <stdio.h>
#include "main.h"
/*
* count - Counter the number of format specifier that exist.
* @fmt: A pointer that points to an array of chars
* Return: Counter
*/
int count(const char *fmt)
{
int count;
for (int i=0; fmt[i]!='\n'; i++)
{
char types[] = {'d', 'u', 's', 'c', 'i'};
for (int j = 0; j < sizeof(types); j++)
{
if (fmt[i] =='%' && fmt[i+1] == types[j])
{
count++;
}
}
}
return (count);
}
/*
* _strlen - Counts number of characters in a string literal.
* @s: A pointer that points to a array of characters
* Return: length of string literal
*/
int _strlen(const char *s)
{
int len = 0;
while( s[len] != '\0')
{
len++;
}
return (len);
}