This commit is contained in:
Camille Chauvet
2023-05-17 16:45:25 +00:00
commit 29ed24d567
619 changed files with 16119 additions and 0 deletions

BIN
Test/c02.tar Normal file

Binary file not shown.

21
Test/c02/ex00/main.c Normal file
View File

@ -0,0 +1,21 @@
#include <unistd.h>
char *ft_strcpy(char *dest, char *src);
void ft_print(char *str)
{
while(*str != 0)
{
write(1, str++, 1);
}
}
int main(void)
{
char *a;
char b[5];
a = "00000";
ft_strncpy(b, a);
ft_print(b);
}

22
Test/c02/ex01/main.c Normal file
View File

@ -0,0 +1,22 @@
#include <unistd.h>
char *ft_strncpy(char *dest, char *src, unsigned int n);
void ft_print(char *str)
{
while(*str != 0)
{
write(1, str++, 1);
}
}
int main(void)
{
char *a;
char b[6];
b[5] = 'd';
a = "00000";
ft_strncpy(b, a, 5);
ft_print(b);
}

17
Test/c02/ex02/main.c Normal file
View File

@ -0,0 +1,17 @@
#include <unistd.h>
int ft_str_is_alpha(char *str);
void ft_putchar(char c)
{
write(1, &c, 1);
}
int main(void)
{
ft_putchar(ft_str_is_alpha("ff")+'0');
ft_putchar(ft_str_is_alpha("dfdf5f")+'0');
ft_putchar(ft_str_is_alpha("GDGFSGF")+48);
ft_putchar(ft_str_is_alpha("FG5DG")+48);
ft_putchar(ft_str_is_alpha("")+48);
}

17
Test/c02/ex03/main.c Normal file
View File

@ -0,0 +1,17 @@
#include <unistd.h>
int ft_str_is_numeric(char *str);
void ft_putchar(char c)
{
write(1, &c, 1);
}
int main()
{
ft_putchar(ft_str_is_numeric("55654")+48);
ft_putchar(ft_str_is_numeric("ssdf5")+48);
ft_putchar(ft_str_is_numeric("5")+48);
ft_putchar(ft_str_is_numeric("55d654")+48);
ft_putchar(ft_str_is_numeric("")+48);
}

17
Test/c02/ex04/main.c Normal file
View File

@ -0,0 +1,17 @@
#include <unistd.h>
int ft_str_is_lowercase(char *str);
void ft_putchar(char c)
{
write(1, &c, 1);
}
int main(void)
{
ft_putchar(ft_str_is_lowercase("ff")+'0');
ft_putchar(ft_str_is_lowercase("dfdf5f")+'0');
ft_putchar(ft_str_is_lowercase("d")+48);
ft_putchar(ft_str_is_lowercase("FG5DG")+48);
ft_putchar(ft_str_is_lowercase("")+48);
}

18
Test/c02/ex05/main.c Normal file
View File

@ -0,0 +1,18 @@
#include <unistd.h>
int ft_str_is_uppercase(char *str);
void ft_putchar(char c)
{
write(1, &c, 1);
}
int main(void)
{
ft_putchar(ft_str_is_uppercase("AAA")+'0');
ft_putchar(ft_str_is_uppercase("dfdf5f")+'0');
ft_putchar(ft_str_is_uppercase("Z")+48);
ft_putchar(ft_str_is_uppercase("FG5DG")+48);
ft_putchar(ft_str_is_uppercase("")+48);
}

17
Test/c02/ex06/main.c Normal file
View File

@ -0,0 +1,17 @@
#include <unistd.h>
int ft_str_is_printable(char *str);
void ft_putchar(char c)
{
write(1, &c, 1);
}
int main(void)
{
ft_putchar(ft_str_is_printable(" ")+48);
ft_putchar(ft_str_is_printable("\n")+48);
ft_putchar(ft_str_is_printable("~")+48);
ft_putchar(ft_str_is_printable("\b")+48);
ft_putchar(ft_str_is_printable("")+48);
}

25
Test/c02/ex07/main.c Normal file
View File

@ -0,0 +1,25 @@
#include <unistd.h>
char *ft_strupcase(char *str);
void ft_print(char *str)
{
while (*str != 0)
write(1, str++, 1);
}
int main(void)
{
char a[4] = "test";
ft_print(ft_strupcase(a));
char b[4] = "TEST";
ft_print(ft_strupcase(b));
char c[4] = "t3st";
ft_print(ft_strupcase(c));
char d[4] = "t3St";
ft_print(ft_strupcase(d));
}

25
Test/c03/ex00/main.c Normal file
View File

@ -0,0 +1,25 @@
#include <stdio.h>
#include <string.h>
int main()
{
char src1[] = "dddd";
char dest1[8] = "ddde";
int result1;
result1 = strcmp(dest1, src1);
printf("%d", result1);
printf("\n");
char src2[] = "dddd";
char dest2[8] = "ddde";
int result2;
result2 = ft_strcmp(dest2, src2);
printf("%d", result2);
return 0;
}

25
Test/c03/ex01/main.c Normal file
View File

@ -0,0 +1,25 @@
#include <stdio.h>
#include <string.h>
int main()
{
char src1[] = "dddd";
char dest1[8] = "ddde";
int result1;
result1 = strncmp(dest1, src1, 4);
printf("%d", result1);
printf("\n");
char src2[] = "dddd";
char dest2[8] = "ddde";
int result2;
result2 = ft_strncmp(dest2, src2, 4);
printf("%d", result2);
return 0;
}

23
Test/c03/ex02/main.c Normal file
View File

@ -0,0 +1,23 @@
#include <stdio.h>
#include <string.h>
int main()
{
char src1[] = "debut";
char dest1[8] = "fin";
strcat(dest1, src1);
printf(dest1);
printf("\n");
char src2[] = "debut";
char dest2[8] = "fin";
ft_strcat(dest2, src2);
printf(dest2);
return 0;
}

29
Test/c03/ex03/main.c Normal file
View File

@ -0,0 +1,29 @@
#include <stdio.h>
#include <string.h>
int main () {
char src1[50], dest1[50];
strcpy(src1, "This is source");
strcpy(dest1, "This is destination");
strncat(dest1, src1, 10);
printf("%s", dest1);
printf("\n");
char src2[50], dest2[50];
strcpy(src2, "This is source");
strcpy(dest2, "This is destination");
ft_strncat(dest2, src2, 10);
printf("%s", dest2);
return(0);
}

28
Test/c03/ex04/main.c Normal file
View File

@ -0,0 +1,28 @@
#include <stdio.h>
#include <string.h>
int main (void) {
char haystack1[20] = "TutorialsPoint";
char needle1[10] = "Point";
char *ret1;
ret1 = strstr(haystack1, needle1);
printf("The substring is: %s\n", ret1);
printf("\n");
char haystack2[20] = "TutorialsPoint";
char needle2[10] = "Point";
char *ret2;
ret2 = ft_strstr(haystack2, needle2);
printf("The substring is: %s\n", ret2);
return(0);
}

12
Test/c03/ex05/main.c Normal file
View File

@ -0,0 +1,12 @@
#include <stdio.h>
int main()
{
char src[] = "hello";
char dest2[5] = "fjff";
int j;
j = ft_strlcat(src, dest2, 5);
printf("%d %s\n", j, dest2);
}

7
Test/c04/ex03/main.c Normal file
View File

@ -0,0 +1,7 @@
#include <stdio.h>
int main ()
{
printf("%d ", ft_atoi(" --++4"));
}

5
Test/c04/ex04/main.c Normal file
View File

@ -0,0 +1,5 @@
int main()
{
ft_putnbr_base(256, "01");
}

7
Test/c04/ex05/main.c Normal file
View File

@ -0,0 +1,7 @@
#include <stdio.h>
int main()
{
printf("%d", ft_atoi_base(" --++kkk", "loki"));
}

9
Test/c05/ex00/main.c Normal file
View File

@ -0,0 +1,9 @@
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
if (argc > 1)
printf("%d", ft_iterative_factoriel(atoi(argv[1])));
}

8
Test/c05/ex01/main.c Normal file
View File

@ -0,0 +1,8 @@
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
if (argc > 1)
printf("%d", ft_recursive_factoriel(atoi(argv[1])));
}

9
Test/c05/ex02/main.c Normal file
View File

@ -0,0 +1,9 @@
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
if (argc > 2)
printf("%d", ft_iterative_power(atoi(argv[1]), atoi(argv[2])));
}

10
Test/c05/ex03/main.c Normal file
View File

@ -0,0 +1,10 @@
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
if (argc > 2)
printf("%d", ft_recursive_power(atoi(argv[1]), atoi(argv[2])));
}

9
Test/c05/ex04/main.c Normal file
View File

@ -0,0 +1,9 @@
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char **argv)
{
if (argc > 1)
printf("%d", ft_fibonacci(atoi(argv[1])));
}

9
Test/c05/ex05/main.c Normal file
View File

@ -0,0 +1,9 @@
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
if (argc > 1)
printf("%d", ft_sqrt(atoi(argv[1])));
}

8
Test/c05/ex06/main.c Normal file
View File

@ -0,0 +1,8 @@
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
if (argc > 1)
printf("%d", ft_is_prime(atoi(argv[1])));
}

7
Test/c05/ex07/main.c Normal file
View File

@ -0,0 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
if (argc > 1)
printf("%d", ft_find_next_prime(atoi(argv[1])));
}

BIN
Test/c07.tar Normal file

Binary file not shown.

12
Test/c07/ex00.c Normal file
View File

@ -0,0 +1,12 @@
#include <stdio.h>
int main()
{
char src[] = "test";
char *dest;
dest = ft_strdup(src);
printf("%s %p \n", src, &src);
printf("%s %p \n", dest, &dest);
}

23
Test/c07/ex01.c Normal file
View File

@ -0,0 +1,23 @@
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
int i;
int min;
int max;
int *tab;
if (argc > 2)
{
i = 0;
min = atoi(argv[1]);
max = atoi(argv[2]);
tab = ft_range(min, max);
while (i < max - min)
{
printf("%d, ", *(tab + i));
i++;
}
}
}

20
Test/c07/ex02.c Normal file
View File

@ -0,0 +1,20 @@
#include <stdio.h>
int main(void)
{
int temp1;
int *temp2;
int **tab;
temp1 = 0;
temp2 =&temp1;
tab = &temp2;
printf("%d", ft_ultimate_range(tab, 0, 10));
printf("\n");
for (int ind = 0; ind<10; ind++ )
{
printf("%i, ", (*tab)[ind]);
}
return (0);
}

14
Test/c08/ex04.c Normal file
View File

@ -0,0 +1,14 @@
int main(int ac, char **av)
{
t_stock_str *tab;
int i;
tab = ft_strs_to_tab(ac, av);
i = 0;
while (i < ac)
{
printf("size = %d, str = %s, copy = %s\n", tab[i].size, tab[i].str, tab[i].copy);
i++;
}
}

View File

@ -0,0 +1,6 @@
typedef struct s_stock_str
{
int size;
char *str;
char *copy;
} t_stock_str;

12
Test/c09/ex05/main.c Normal file
View File

@ -0,0 +1,12 @@
#include "ft_stock_str.h"
void ft_show_tab(struct s_stock_str *par);
struct s_stock_str *ft_strs_to_tab(int ac, char **av);
int main(int ac, char **av)
{
t_stock_str *tab;
tab = ft_strs_to_tab(ac, av);
ft_show_tab(tab);
}