Skip to content

Commit cf439f2

Browse files
committed
adding wild number
1 parent 48103ab commit cf439f2

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

0x08-recursion/101-wildcmp.c

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#include "main.h"
2+
3+
/**
4+
* wildcmp - compares two strings
5+
* @s1: string to compare
6+
* @s2: string with wild character
7+
* Return: return success
8+
*/
9+
int wildcmp(char *s1, char *s2)
10+
{
11+
if (*s1 == '\0' && *s2 == '\0')
12+
return (1);
13+
14+
if (*s1 == *s2)
15+
return (wildcmp(s1 + 1, s2 + 1));
16+
17+
if (*s2 == '*')
18+
{
19+
if (*s2 == '*' && *(s2 + 1) != '\0' && *s1 == '\0')
20+
return (0);
21+
if (wildcmp(s1, s2 + 1) || wildcmp(s1 + 1, s2))
22+
return (1);
23+
}
24+
25+
return (0);
26+
}

0 commit comments

Comments
 (0)