0
0
This commit is contained in:
Guy Baconniere
2021-08-16 13:27:55 +02:00
parent c665b6c546
commit 0909750997
21 changed files with 431 additions and 14 deletions

View File

@@ -0,0 +1,21 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlen.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/13 09:03:26 by gbaconni #+# #+# */
/* Updated: 2021/08/13 09:09:57 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
int ft_strlen(char *str)
{
char *p_str;
p_str = str;
while (*p_str != '\0')
p_str++;
return (p_str - str);
}

View File

@@ -0,0 +1,32 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gbaconni <marvin@42lausanne.ch> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/13 09:02:59 by gbaconni #+# #+# */
/* Updated: 2021/08/13 09:03:17 by gbaconni ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
int ft_strlen(char *str);
int main(void)
{
char str[32];
int result;
printf("Input String [max 31]: ");
scanf("%s", str);
result = ft_strlen(str);
printf("str=%s result=%d (ft_strlen)\n", str, result);
result = strlen(str);
printf("str=%s result=%d (strlen)\n", str, result);
return (0);
}

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