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

28
C_03/git/ex00/ft_strcmp.c Normal file
View File

@@ -0,0 +1,28 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcmp.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/12 12:14:57 by gbaconni #+# #+# */
/* Updated: 2021/08/12 14:50:37 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
int ft_strcmp(char *s1, char *s2)
{
char c1;
char c2;
c1 = '\0';
c2 = '\0';
while (c1 == c2)
{
c1 = *s1++;
c2 = *s2++;
if (c1 == '\0')
break ;
}
return (c1 - c2);
}

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

@@ -0,0 +1,35 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/12 12:15:09 by gbaconni #+# #+# */
/* Updated: 2021/08/12 12:28:31 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
int ft_strcmp(char *s1, char *s2);
int main(void)
{
char s1[32];
char s2[32];
int result;
printf("Input String #1 [max 31]: ");
scanf("%s", s1);
printf("Input String #2 [max 31]: ");
scanf("%s", s2);
result = ft_strcmp(s1, s2);
printf("s1=%s s2=%s result=%d (ft_strcmp)\n", s1, s2, result);
result = strcmp(s1, s2);
printf("s1=%s s2=%s result=%d (strcmp)\n", s1, s2, result);
return (0);
}

8
C_03/git/ex00/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