sync
This commit is contained in:
27
C_Piscine_C_03/git/ex01/ft_strncmp.copy.c
Normal file
27
C_Piscine_C_03/git/ex01/ft_strncmp.copy.c
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* ft_strncmp.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: dgloriod <marvin@42lausanne.ch> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2021/08/09 11:32:49 by dgloriod #+# #+# */
|
||||||
|
/* Updated: 2021/08/18 11:44:44 by gbaconni ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
int ft_strncmp(char *s1, char *s2, unsigned int n)
|
||||||
|
{
|
||||||
|
unsigned int i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (i < n)
|
||||||
|
{
|
||||||
|
if (s1[i] > s2[i])
|
||||||
|
return (1);
|
||||||
|
else if (s1[i] < s2[i])
|
||||||
|
return (-1);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
37
C_Piscine_C_03/git/ex01/t.c
Normal file
37
C_Piscine_C_03/git/ex01/t.c
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* main.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2021/08/12 15:16:20 by gbaconni #+# #+# */
|
||||||
|
/* Updated: 2021/08/18 12:00:04 by gbaconni ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
int ft_strncmp(char *s1, char *s2, unsigned int n);
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
char *s1 = "a";
|
||||||
|
char *s2 = "a";
|
||||||
|
unsigned int n = 65536;
|
||||||
|
int result;
|
||||||
|
|
||||||
|
while (n < 80000)
|
||||||
|
{
|
||||||
|
printf("[%d]:\n", n);
|
||||||
|
result = strncmp(s1, s2, n);
|
||||||
|
printf("s1=%s s2=%s n=%d result=%d (strncmp)\n", s1, s2, n, result);
|
||||||
|
result = ft_strncmp(s1, s2, n);
|
||||||
|
printf("s1=%s s2=%s n=%d result=%d (ft_strncmp)\n", s1, s2, n, result);
|
||||||
|
n++;
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
7
C_Piscine_C_03/git/ex01/t.sh
Executable file
7
C_Piscine_C_03/git/ex01/t.sh
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
norminette -R CheckForbiddenSourceHeader ft_strncmp.copy.c
|
||||||
|
gcc -Wall -Wextra -Werror -o a.out ft_strncmp.copy.c t.c
|
||||||
|
echo $(basename $PWD):
|
||||||
|
./a.out
|
||||||
|
rm -f a.out
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
|
/* By: gbaconni <gbaconni@42lausanne.ch> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2021/08/18 10:53:52 by gbaconni #+# #+# */
|
/* Created: 2021/08/18 10:53:52 by gbaconni #+# #+# */
|
||||||
/* Updated: 2021/08/18 12:12:03 by gbaconni ### ########.fr */
|
/* Updated: 2021/08/18 14:03:38 by gbaconni ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
@@ -18,7 +18,7 @@ int ft_find_next_prime(int nb)
|
|||||||
r = 0;
|
r = 0;
|
||||||
while (r == 0)
|
while (r == 0)
|
||||||
{
|
{
|
||||||
if (nb == 0 || nb == 1)
|
if (nb <= 0 || nb == 1)
|
||||||
r = 0;
|
r = 0;
|
||||||
else
|
else
|
||||||
r = 1;
|
r = 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user