-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_strnstr.c
More file actions
49 lines (45 loc) · 1.55 KB
/
Copy pathft_strnstr.c
File metadata and controls
49 lines (45 loc) · 1.55 KB
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
40
41
42
43
44
45
46
47
48
49
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strnstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dpadenko <dpadenko@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/09/08 14:15:37 by dpadenko #+# #+# */
/* Updated: 2023/09/20 11:23:46 by dpadenko ### ########.fr */
/* */
/* ************************************************************************** */
#include <string.h>
#include "libft.h"
#include <bsd/string.h>
char *ft_strnstr(const char *big, const char *little, size_t len)
{
size_t i;
if (*little == '\0')
return ((char *)big);
while (*big && len)
{
i = 0;
while (big[i] == little[i] && little[i] != '\0' && i < len)
i++;
if (little[i] == '\0')
return ((char *)big);
big++;
len--;
}
return (NULL);
}
/*
#include <stdio.h>
int main(void)
{
const char largestring[30] = "aaabcabcd";
const char smallstring[10] = "aabc";
char *ptr1;
//char *ptr2;
ptr1 = ft_strnstr(largestring, smallstring, -1);
//ptr2 = strnstr(largestring, smallstring, 6);
printf("%s\n", ptr1);
//printf("%s\n", ptr2);
}
*/