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
Correction/thellego/a.out Executable file

Binary file not shown.

View File

@ -0,0 +1,39 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: thellego <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/16 13:44:49 by thellego #+# #+# */
/* Updated: 2022/07/20 10:51:58 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
char *ft_strcpy(char *dest, char *src)
{
int counter;
counter = 0;
while (*src != '\0')
{
dest[counter] = src[counter];
counter++;
}
dest[counter] = '\0';
return (dest);
}
int main()
{
char tab1[120] = "Hello world jjhaflhsuid ai;eiwjejvhds jdg";
char tab[120] = "";
tab1[0] = 8;
ft_strcpy(tab, tab1);
printf("%s\n", tab1);
printf("%s\n", tab);
}

View File

@ -0,0 +1,42 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: thellego <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/17 09:22:49 by thellego #+# #+# */
/* Updated: 2022/07/20 10:53:02 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strncpy(char *dest, char *src, unsigned int n)
{
unsigned int counter;
counter = 0;
while (counter < n && src[counter] != '\0')
{
dest[counter] = src[counter];
counter++;
}
while (counter < n)
{
dest[counter] = '\0';
counter++;
}
if (src[counter] == '\0')
dest[counter] = '\0';
return (dest);
}
#include <stdio.h>
int main()
{
char tab1[120] = "hello world jjhaflhsuid ai;eiwjejvhds jdg";
char tab[120] = "";
printf("%s\n", tab);
ft_strncpy(tab, tab1, 10);
printf("%s\n", tab1);
printf("%s\n", tab);
}

View File

@ -0,0 +1,31 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_alpha.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: thellego <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/17 09:49:06 by thellego #+# #+# */
/* Updated: 2022/07/17 19:21:41 by thellego ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_alpha(char *str)
{
int counter;
counter = 0;
while (str[counter])
{
if ((65 <= str[counter] && str[counter] <= 90)
|| (97 <= str[counter] && str[counter] <= 122))
{
counter++;
}
else
{
return (0);
}
}
return (1);
}

View File

@ -0,0 +1,35 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_numeric.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: thellego <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/17 10:43:58 by thellego #+# #+# */
/* Updated: 2022/07/17 10:54:48 by thellego ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_numeric(char *str)
{
int counter;
counter = 0;
while (str[counter])
{
if (48 <= str[counter] && str[counter] <= 57)
{
counter++;
}
else
{
return (0);
}
}
return (1);
}
/* int main()
{
char tab1[120] = "0123456789iiiiijd;s";
ft_str_is_numeric(tab1);
}*/

View File

@ -0,0 +1,35 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_lowercase.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: thellego <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/17 12:01:10 by thellego #+# #+# */
/* Updated: 2022/07/17 12:09:09 by thellego ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_lowercase(char *str)
{
int counter;
counter = 0;
while (str[counter])
{
if (97 <= str[counter] && str[counter] <= 122)
{
counter++;
}
else
{
return (0);
}
}
return (1);
}
/* int main()
{
char tab1[120] = "hello world";
ft_str_is_lowercase(tab1);
} */

View File

@ -0,0 +1,35 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_uppercase.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: thellego <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/17 12:10:02 by thellego #+# #+# */
/* Updated: 2022/07/17 12:14:24 by thellego ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_uppercase(char *str)
{
int counter;
counter = 0;
while (str[counter])
{
if (65 <= str[counter] && str[counter] <= 90)
{
counter++;
}
else
{
return (0);
}
}
return (1);
}
/* int main()
{
char tab1[120] = "QWERTYUIOPASDFGHJKLZXCVBNMeL";
ft_str_is_uppercase(tab1);
}*/

View File

@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_printable.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: thellego <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/17 12:17:42 by thellego #+# #+# */
/* Updated: 2022/07/17 20:32:27 by thellego ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_printable(char *str)
{
int counter;
counter = 0;
while (str[counter])
{
if (32 <= str[counter] && str[counter] <= 126)
{
counter++;
}
else
{
return (0);
}
}
return (1);
}
/* int main(){
char tab1[120] = "QW ERklzxcvbnm,./;'][=-0987654321`~!@#$%^&*()_+}{";
ft_str_is_printable(tab1);
} */

View File

@ -0,0 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strupcase.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: thellego <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/17 12:25:28 by thellego #+# #+# */
/* Updated: 2022/07/17 13:06:29 by thellego ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strupcase(char *str)
{
int counter;
counter = 0;
while (str[counter])
{
if (97 <= str[counter] && str[counter] <= 122)
str[counter] = str[counter] - 32;
counter++;
}
return (str);
}
/* int main(){
char tab1[120] = "Hyurga uriaujhdljhnb9";
ft_strupcase(tab1);
printf("%s", tab1);
} */

View File

@ -0,0 +1,30 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlowcase.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: thellego <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/17 13:07:13 by thellego #+# #+# */
/* Updated: 2022/07/17 13:10:03 by thellego ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strlowcase(char *str)
{
int counter;
counter = 0;
while (str[counter])
{
if (65 <= str[counter] && str[counter] <= 90)
str[counter] = str[counter] + 32;
counter++;
}
return (str);
}
/* int main(){
char tab1[120] = "Hfdh HELLO WORLD /.,'[-009";
ft_strlowcase(tab1);
printf("%s", tab1);
} */

View File

@ -0,0 +1,47 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strcapitalize.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: thellego <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/17 15:19:23 by thellego #+# #+# */
/* Updated: 2022/07/20 10:59:02 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
char *ft_strcapitalize(char *str)
{
int counter;
counter = 0;
while (str[counter])
{
if (counter == 0)
{
if (97 <= str[counter] && str[counter] <= 122)
{
str[counter] = str[counter] - 32;
}
}
if (97 <= str[counter] && str[counter] <= 122)
{
if ((32 <= str[counter - 1] && str[counter - 1] <= 47)
|| (58 <= str[counter - 1] && str[counter - 1] <= 64)
|| (91 <= str[counter - 1] && str[counter - 1] <= 96)
|| (123 <= str[counter - 1] && str[counter - 1] <= 126))
{
str[counter] = str[counter] - 32;
}
}
counter++;
}
return (str);
}
int main(){
char tab[90] = "salut, cOmment tu vas ? 42mots quarante-deux; cinquante+et+un";
ft_strcapitalize(tab);
printf("%s", tab);
}

View File

@ -0,0 +1,41 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strlcpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: thellego <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/18 09:44:45 by thellego #+# #+# */
/* Updated: 2022/07/20 11:02:34 by cchauvet ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
#include <unistd.h>
unsigned int ft_strlcpy(char *dest, char *src, unsigned int size)
{
unsigned int i;
i = 0;
while (i < size - 1 && src[i] != '\0')
{
dest[i] = src[i];
i++;
}
dest[i] = '\0';
while (src[i] != '\0')
{
i++;
}
return (i);
}
int main()
{
char tab1[12] = "hello world";
char tab[5] = "";
printf("%s\n", tab);
printf("%d\n", ft_strlcpy(tab, tab1, 11));
printf("%s\n", tab1);
printf("%s\n", tab);
}

View File

@ -0,0 +1,41 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_putstr_non_printable.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: thellego <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/07/18 15:54:18 by thellego #+# #+# */
/* Updated: 2022/07/18 22:39:25 by thellego ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
void ft_printhexa(int i)
{
int nb;
nb = i / 16;
write(1, "\\", 1);
write(1, &"0123456789abcdef"[nb % 16], 1);
write(1, &"0123456789abcdef"[i % 16], 1);
}
void ft_putstr_non_printable(char *str)
{
int i;
i = 0;
while (str[i])
{
if (str[i] >= 32 && str[i] <= 126)
write(1, &str[i], 1);
else
ft_printhexa(str[i]);
i++;
}
}
/*int main(void){
ft_putstr_non_printable("Coucou\ntu vas bien ?");
}*/