commit
This commit is contained in:
34
C_02/tests_C02/ex00.c
Normal file
34
C_02/tests_C02/ex00.c
Normal file
@@ -0,0 +1,34 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ex00.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tkondrac <tkondrac@student.42lausan> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/08/08 15:02:50 by tkondrac #+# #+# */
|
||||
/* Updated: 2021/08/08 17:02:48 by tkondrac ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "../ex00/ft_strcpy.c"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char s[42];
|
||||
char *d;
|
||||
char *r;
|
||||
|
||||
d = (char*)malloc(43 * sizeof(char));
|
||||
printf("Enter string (max 42 char): ");
|
||||
scanf("%s", s);
|
||||
r = ft_strcpy(d, s);
|
||||
printf("destination : %s | return : %s\n", d, r);
|
||||
free(d);
|
||||
d = (char*)malloc(43 * sizeof(char));
|
||||
printf("strcpy : %s\n", strcpy(d, s));
|
||||
free(d);
|
||||
return(0);
|
||||
}
|
||||
57
C_02/tests_C02/ex01.c
Normal file
57
C_02/tests_C02/ex01.c
Normal file
@@ -0,0 +1,57 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ex01.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tkondrac <tkondrac@student.42lausan> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/08/08 15:03:03 by tkondrac #+# #+# */
|
||||
/* Updated: 2021/08/08 16:59:55 by tkondrac ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "../ex01/ft_strncpy.c"
|
||||
#include "rand_string.c"
|
||||
|
||||
int ft_test(char *src, unsigned int l);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
ft_test("0123456789", 15);
|
||||
ft_test("test", 8);
|
||||
ft_test("0123456789" , 3);
|
||||
ft_test("un autre test" , 0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int ft_test(char *src, unsigned int l)
|
||||
{
|
||||
char *dest;
|
||||
char *dest2;
|
||||
int i;
|
||||
|
||||
i = 0;
|
||||
dest = (char*)malloc(11 * sizeof(char));
|
||||
while(i < 10)
|
||||
{
|
||||
*(dest + i) = '0';
|
||||
i++;
|
||||
}
|
||||
*(dest + i) = '\0';
|
||||
dest2 = ft_strncpy(dest, src, l);
|
||||
printf("-------------\nTest\nsrc string : %s | copy lenght : %u\ndest string : %s | output string : %s\n", src, l, dest, dest2);
|
||||
// Strncpy tests
|
||||
while(i < 10)
|
||||
{
|
||||
*(dest + i) = '0';
|
||||
i++;
|
||||
}
|
||||
*(dest + i) = '\0';
|
||||
dest2 = strncpy(dest, src, l);
|
||||
printf("TEST string : %s | output TEST : %s\n", dest, dest2);
|
||||
free(dest);
|
||||
return (0);
|
||||
}
|
||||
26
C_02/tests_C02/ex02.c
Normal file
26
C_02/tests_C02/ex02.c
Normal file
@@ -0,0 +1,26 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ex02.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tkondrac <tkondrac@student.42lausan> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/08/08 15:03:45 by tkondrac #+# #+# */
|
||||
/* Updated: 2021/08/08 15:03:53 by tkondrac ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "../ex02/ft_str_is_alpha.c"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char c[42];
|
||||
|
||||
while(1)
|
||||
{
|
||||
scanf("%s", c);
|
||||
printf("is alpha ? : %d\n", ft_str_is_alpha(c));
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
26
C_02/tests_C02/ex03.c
Normal file
26
C_02/tests_C02/ex03.c
Normal file
@@ -0,0 +1,26 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ex03.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tkondrac <tkondrac@student.42lausan> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/08/08 15:03:58 by tkondrac #+# #+# */
|
||||
/* Updated: 2021/08/08 15:04:00 by tkondrac ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "../ex03/ft_str_is_numeric.c"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char c[42];
|
||||
|
||||
while(1)
|
||||
{
|
||||
scanf("%s", c);
|
||||
printf("is numeric ? : %d\n", ft_str_is_numeric(c));
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
26
C_02/tests_C02/ex04.c
Normal file
26
C_02/tests_C02/ex04.c
Normal file
@@ -0,0 +1,26 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ex04.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tkondrac <tkondrac@student.42lausan> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/08/08 15:07:35 by tkondrac #+# #+# */
|
||||
/* Updated: 2021/08/08 15:11:12 by tkondrac ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "../ex04/ft_str_is_lowercase.c"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char c[42];
|
||||
|
||||
while(1)
|
||||
{
|
||||
scanf("%s", c);
|
||||
printf("is lowercase ? : %d\n", ft_str_is_lowercase(c));
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
26
C_02/tests_C02/ex05.c
Normal file
26
C_02/tests_C02/ex05.c
Normal file
@@ -0,0 +1,26 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ex05.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tkondrac <tkondrac@student.42lausan> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/08/08 15:13:08 by tkondrac #+# #+# */
|
||||
/* Updated: 2021/08/08 15:13:13 by tkondrac ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "../ex05/ft_str_is_uppercase.c"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char c[42];
|
||||
|
||||
while(1)
|
||||
{
|
||||
scanf("%s", c);
|
||||
printf("is uppercase ? : %d\n", ft_str_is_uppercase(c));
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
26
C_02/tests_C02/ex06.c
Normal file
26
C_02/tests_C02/ex06.c
Normal file
@@ -0,0 +1,26 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ex06.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tkondrac <tkondrac@student.42lausan> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/08/08 15:13:19 by tkondrac #+# #+# */
|
||||
/* Updated: 2021/08/08 15:13:37 by tkondrac ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "../ex06/ft_str_is_printable.c"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char c[42];
|
||||
|
||||
while(1)
|
||||
{
|
||||
scanf("%s", c);
|
||||
printf("is printable ? : %d\n", ft_str_is_printable(c));
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
26
C_02/tests_C02/ex07.c
Normal file
26
C_02/tests_C02/ex07.c
Normal file
@@ -0,0 +1,26 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ex07.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tkondrac <tkondrac@student.42lausan> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/08/08 15:13:42 by tkondrac #+# #+# */
|
||||
/* Updated: 2021/08/08 15:13:47 by tkondrac ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "../ex07/ft_strupcase.c"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char c[42];
|
||||
|
||||
while(1)
|
||||
{
|
||||
scanf("%s", c);
|
||||
printf("upcased : %s\n", ft_strupcase(c));
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
26
C_02/tests_C02/ex08.c
Normal file
26
C_02/tests_C02/ex08.c
Normal file
@@ -0,0 +1,26 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ex08.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tkondrac <tkondrac@student.42lausan> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/08/08 15:13:52 by tkondrac #+# #+# */
|
||||
/* Updated: 2021/08/08 15:13:55 by tkondrac ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "../ex08/ft_strlowcase.c"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char c[42];
|
||||
|
||||
while(1)
|
||||
{
|
||||
scanf("%s", c);
|
||||
printf("lowcased : %s\n", ft_strlowcase(c));
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
23
C_02/tests_C02/ex09.c
Normal file
23
C_02/tests_C02/ex09.c
Normal file
@@ -0,0 +1,23 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ex09.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tkondrac <tkondrac@student.42lausan> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/08/08 15:14:28 by tkondrac #+# #+# */
|
||||
/* Updated: 2021/08/08 15:14:31 by tkondrac ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "../ex09/ft_strcapitalize.c"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char c[] = "salut, comment tu vas ? 42mots quarante-deux; cinquante+et+un";
|
||||
|
||||
printf("original :%s\n", c);
|
||||
printf("capitalized :%s\n", ft_strcapitalize(c));
|
||||
return (0);
|
||||
}
|
||||
47
C_02/tests_C02/ex10.c
Normal file
47
C_02/tests_C02/ex10.c
Normal file
@@ -0,0 +1,47 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ex10.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tkondrac <tkondrac@student.42lausan> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/08/08 15:16:23 by tkondrac #+# #+# */
|
||||
/* Updated: 2021/08/11 15:01:07 by gbaconni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "../ex10/ft_strlcpy.c"
|
||||
#include "rand_string.c"
|
||||
int ft_test(unsigned int s, unsigned int d);
|
||||
|
||||
int main(void)
|
||||
{
|
||||
ft_test(15 , 8);
|
||||
ft_test(8 , 15);
|
||||
ft_test(10 , 2);
|
||||
ft_test(5 , 0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int ft_test(unsigned int s, unsigned int d)
|
||||
{
|
||||
char *dest;
|
||||
char *src;
|
||||
unsigned int n;
|
||||
size_t t;
|
||||
|
||||
dest = (char*)malloc(d * sizeof(char));
|
||||
src = rand_string(s);
|
||||
n = ft_strlcpy(dest, src, d);
|
||||
printf("-------------\nTest\nsrc string : %s | dest size : %u\ndest string : %s | output size : %d\n", src, d, dest, n);
|
||||
free(dest);
|
||||
dest = (char*)malloc(d * sizeof(char));
|
||||
t = strlcpy(dest, src, d);
|
||||
printf("TEST string : %s | output TEST : %d\n", dest, n);
|
||||
free(dest);
|
||||
free(src);
|
||||
return (0);
|
||||
}
|
||||
26
C_02/tests_C02/ex11.c
Normal file
26
C_02/tests_C02/ex11.c
Normal file
@@ -0,0 +1,26 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* ex11.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tkondrac <tkondrac@student.42lausan> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/08/08 15:48:26 by tkondrac #+# #+# */
|
||||
/* Updated: 2021/08/11 16:50:37 by gbaconni ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <stdio.h>
|
||||
#include "../ex11/ft_putstr_non_printable.c"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char c[] = "special : | speciaux : ";
|
||||
|
||||
c[10] = '\n';
|
||||
c[25] = 14;
|
||||
c[26] = 127;
|
||||
printf("%s\n ------ \n", c);
|
||||
ft_putstr_non_printable(c);
|
||||
return (0);
|
||||
}
|
||||
8
C_02/tests_C02/main.sh
Executable file
8
C_02/tests_C02/main.sh
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
test=$1
|
||||
set -e
|
||||
norminette -R CheckForbiddenSourceHeader ../$test/ft_*.c
|
||||
gcc -Wall -Wextra -Werror -o a.out $test.c
|
||||
#gcc -o a.out $test.c
|
||||
./a.out
|
||||
rm -f a.out
|
||||
31
C_02/tests_C02/rand_string.c
Normal file
31
C_02/tests_C02/rand_string.c
Normal file
@@ -0,0 +1,31 @@
|
||||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* rand_string.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: tkondrac <marvin@42lausanne.ch> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2021/08/08 12:07:16 by tkondrac #+# #+# */
|
||||
/* Updated: 2021/08/08 13:04:23 by tkondrac ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
char *rand_string(unsigned int size)
|
||||
{
|
||||
char *c;
|
||||
unsigned int i;
|
||||
|
||||
c = (char*)malloc(size * sizeof(char));
|
||||
i = 0;
|
||||
srand(time(0));
|
||||
while(i < size - 1)
|
||||
{
|
||||
*(c + i) = (rand() % 94) + 32;
|
||||
i++;
|
||||
}
|
||||
*(c + i) = '\0';
|
||||
return (c);
|
||||
}
|
||||
Reference in New Issue
Block a user