ex00
This commit is contained in:
parent
cea241ebc2
commit
385904df49
|
@ -0,0 +1,50 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ft_strstr.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/24 02:23:28 by tischmid #+# #+# */
|
||||
/* Updated: 2023/03/24 03:18:35 by tischmid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
char *ft_strstr(char *str, char *to_find)
|
||||
{
|
||||
int offset;
|
||||
char *orig_to_find;
|
||||
|
||||
orig_to_find = to_find;
|
||||
while (*str)
|
||||
{
|
||||
offset = 0;
|
||||
while (*(to_find + offset))
|
||||
{
|
||||
if (*(to_find + offset) != *(str + offset))
|
||||
break ;
|
||||
++offset;
|
||||
}
|
||||
if (!*(to_find + offset))
|
||||
return (str);
|
||||
to_find = orig_to_find;
|
||||
++str;
|
||||
}
|
||||
return ((void *) 0);
|
||||
}
|
||||
|
||||
/* ////
|
||||
#include <stdio.h>
|
||||
#define STR1 "hello"
|
||||
#define STR2 "aa"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
printf("String to search in: %s\n", STR1);
|
||||
printf("String to find: %s\n", STR2);
|
||||
printf("Result: %s\n", ft_strstr(STR1, STR2));
|
||||
return (0);
|
||||
}
|
||||
*/ ////
|
|
@ -6,11 +6,12 @@
|
|||
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/24 03:19:16 by tischmid #+# #+# */
|
||||
/* Updated: 2023/03/27 00:48:27 by tischmid ### ########.fr */
|
||||
/* Updated: 2023/03/28 02:49:49 by tischmid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
unsigned int ft_strlcat(char *dest, char *src, unsigned int size)
|
||||
{
|
||||
int src_len;
|
||||
|
@ -29,10 +30,9 @@ unsigned int ft_strlcat(char *dest, char *src, unsigned int size)
|
|||
while (*o_src++)
|
||||
++src_len;
|
||||
return (src_len);
|
||||
|
||||
}
|
||||
|
||||
#define START
|
||||
/* ////
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void)
|
||||
|
@ -43,3 +43,4 @@ int main(void)
|
|||
printf("%s\n", s);
|
||||
return (0);
|
||||
}
|
||||
*/ ////
|
||||
|
|
Loading…
Reference in New Issue