sync
This commit is contained in:
@@ -1,27 +0,0 @@
|
|||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* 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);
|
|
||||||
}
|
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
/* ************************************************************************** */
|
|
||||||
/* */
|
|
||||||
/* ::: :::::::: */
|
|
||||||
/* 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);
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
#!/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
|
|
||||||
Reference in New Issue
Block a user