0
0
This commit is contained in:
Guy Baconniere
2021-08-20 10:02:38 +02:00
parent 5aa02c94b5
commit d30270c485
354 changed files with 0 additions and 0 deletions

31
C_03/git/ex04/ft_strstr.c Normal file
View File

@@ -0,0 +1,31 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strstr.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/12 16:49:31 by gbaconni #+# #+# */
/* Updated: 2021/08/12 17:11:14 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
char *ft_strstr(char *str, char *to_find)
{
unsigned int i;
unsigned int j;
i = 0;
while (str[i] != '\0')
{
j = 0;
while (str[i + j] != '\0' && str[i + j] == to_find[j])
j++;
if (to_find[j] == '\0')
return (str + i);
i++;
}
return (NULL);
}

35
C_03/git/ex04/main.c Normal file
View File

@@ -0,0 +1,35 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/12 16:49:41 by gbaconni #+# #+# */
/* Updated: 2021/08/12 17:07:20 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
char *ft_strstr(char *str, char *to_find);
int main(void)
{
char str[32];
char to_find[32];
char *r;
printf("Input String #1 [max 31]: ");
scanf("%s", str);
printf("Input String #2 [max 31]: ");
scanf("%s", to_find);
r = ft_strstr(str, to_find);
printf("str=%s to_find=%s result=%s (ft_strstr)\n", str, to_find, r);
r = strstr(str, to_find);
printf("str=%s to_find=%s result=%s (strstr)\n", str, to_find, r);
return (0);
}

8
C_03/git/ex04/main.sh Executable file
View File

@@ -0,0 +1,8 @@
#!/bin/sh
set -e
#norminette -R CheckForbiddenSourceHeader ft_*.c
norminette -R CheckForbiddenSourceHeader
gcc -Wall -Wextra -Werror -o a.out *.c
echo $(basename $PWD):
./a.out
rm -f a.out