Bug fix everything

This commit is contained in:
Timo Schmidt 2023-03-26 01:05:38 +01:00
parent 34fe9c3358
commit 45f88f999a
8 changed files with 45 additions and 68 deletions

View File

@ -6,18 +6,15 @@
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */ /* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/19 05:59:56 by tischmid #+# #+# */ /* Created: 2023/03/19 05:59:56 by tischmid #+# #+# */
/* Updated: 2023/03/24 23:17:31 by tischmid ### ########.fr */ /* Updated: 2023/03/26 00:53:19 by tischmid ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
char *ft_strcpy(char *s1, char *s2) char *ft_strcpy(char *s1, char *s2)
{ {
int i; while (*s2)
*s1++ = *s2++;
i = -1; *s1 = 0;
while (s2[++i] != '\0')
s1[i] = s2[i];
s1[i] = '\0';
return (s1); return (s1);
} }

View File

@ -6,33 +6,27 @@
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */ /* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/19 10:33:26 by tischmid #+# #+# */ /* Created: 2023/03/19 10:33:26 by tischmid #+# #+# */
/* Updated: 2023/03/24 01:36:25 by tischmid ### ########.fr */ /* Updated: 2023/03/26 01:00:36 by tischmid ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
int ft_str_is_alpha(char *str) int ft_str_is_alpha(char *str)
{ {
int i; while ((*str | 32) >= 'a' && (*str | 32) <= 'z')
++str;
i = 0; return (!*str);
while ((str[i] | 32) >= 'a' && (str[i] | 32) <= 'z')
{
++i;
}
return (str[i] == '\0');
} }
/* //// /* ////
#include <stdio.h> #include <stdio.h>
#define STR "aa" #define STR1 "abcdefg"
int main(void) int main(void)
{ {
printf(STR "\n"); if (ft_str_is_alpha(STR1))
if (ft_str_is_alpha(STR)) printf(STR1 " contains only alphabetical characters\n");
printf("Contains only alphabetical characters\n");
else else
printf("Contains non-alphabetical characters\n"); printf(STR1 " contains non-alphabetical characters\n");
return (0); return (0);
} }
*/ //// */ ////

View File

@ -6,33 +6,27 @@
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */ /* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/19 10:33:26 by tischmid #+# #+# */ /* Created: 2023/03/19 10:33:26 by tischmid #+# #+# */
/* Updated: 2023/03/24 01:36:42 by tischmid ### ########.fr */ /* Updated: 2023/03/26 01:01:32 by tischmid ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
int ft_str_is_numeric(char *str) int ft_str_is_numeric(char *str)
{ {
int i; while (*str >= '0' && *str <= '9')
++str;
i = 0; return (!*str);
while (str[i] >= '0' && str[i] <= '9')
{
++i;
}
return (str[i] == '\0');
} }
/* //// /* ////
#include <stdio.h> #include <stdio.h>
#define STR "0123456789" #define STR1 "0123456789"
int main(void) int main(void)
{ {
printf(STR "\n"); if (ft_str_is_numeric(STR1))
if (ft_str_is_numeric(STR)) printf(STR1 " is numeric\n");
printf("Is numeric\n");
else else
printf("Is not numeric\n"); printf(STR1 " is not numeric\n");
return (0); return (0);
} }
*/ //// */ ////

View File

@ -6,7 +6,7 @@
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */ /* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/19 11:03:56 by tischmid #+# #+# */ /* Created: 2023/03/19 11:03:56 by tischmid #+# #+# */
/* Updated: 2023/03/24 01:36:52 by tischmid ### ########.fr */ /* Updated: 2023/03/24 23:21:18 by tischmid ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -19,15 +19,14 @@ int ft_str_is_lowercase(char *str)
/* //// /* ////
#include <stdio.h> #include <stdio.h>
#define STR "abcd" #define STR1 "abcd"
int main(void) int main(void)
{ {
printf(STR "\n"); if (ft_str_is_lowercase(STR1))
if (ft_str_is_lowercase(STR)) printf(STR1 " is all lowercase\n");
printf("Is all lowercase\n");
else else
printf("Contains non-lowercase characters\n"); printf(STR1 " contains non-lowercase characters\n");
return (0); return (0);
} }
*/ //// */ ////

View File

@ -6,33 +6,27 @@
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */ /* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/19 11:03:56 by tischmid #+# #+# */ /* Created: 2023/03/19 11:03:56 by tischmid #+# #+# */
/* Updated: 2023/03/24 01:36:59 by tischmid ### ########.fr */ /* Updated: 2023/03/26 01:02:03 by tischmid ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
int ft_str_is_uppercase(char *str) int ft_str_is_uppercase(char *str)
{ {
int i; while (*str >= 'A' && *str <= 'Z')
++str;
i = 0; return (!*str);
while (str[i] >= 'A' && str[i] <= 'Z')
{
++i;
}
return (str[i] == '\0');
} }
/* //// /* ////
#include <stdio.h> #include <stdio.h>
#define STR "ABCDEf" #define STR1 "ABCDEF"
int main(void) int main(void)
{ {
printf(STR "\n"); if (ft_str_is_uppercase(STR1))
if (ft_str_is_uppercase(STR)) printf(STR1 " is all uppercase\n");
printf("Is all uppercase\n");
else else
printf("Contains non-uppercase characters\n"); printf(STR1 " contains non-uppercase characters\n");
return (0); return (0);
} }
*/ //// */ ////

View File

@ -6,7 +6,7 @@
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */ /* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/19 11:03:56 by tischmid #+# #+# */ /* Created: 2023/03/19 11:03:56 by tischmid #+# #+# */
/* Updated: 2023/03/24 01:37:11 by tischmid ### ########.fr */ /* Updated: 2023/03/24 23:20:56 by tischmid ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -24,15 +24,14 @@ int ft_str_is_printable(char *str)
/* //// /* ////
#include <stdio.h> #include <stdio.h>
#define STR "BCDEF ~~~ " #define STR1 "BCDEF ~~~ "
int main(void) int main(void)
{ {
printf(STR "\n"); if (ft_str_is_printable(STR1))
if (ft_str_is_printable(STR)) printf(STR1 " is printable\n");
printf("Is printable\n");
else else
printf("Is not printable\n"); printf(STR1 " is not printable\n");
return (0); return (0);
} }
*/ //// */ ////

View File

@ -6,22 +6,22 @@
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */ /* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/19 11:18:13 by tischmid #+# #+# */ /* Created: 2023/03/19 11:18:13 by tischmid #+# #+# */
/* Updated: 2023/03/24 01:37:20 by tischmid ### ########.fr */ /* Updated: 2023/03/26 01:03:20 by tischmid ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
char *ft_strupcase(char *str) char *ft_strupcase(char *str)
{ {
char *orig_str; char *o_str;
orig_str = str; o_str = str;
while (*str) while (*str)
{ {
if (*str >= 'a' && *str <= 'z') if (*str >= 'a' && *str <= 'z')
*str &= 95; *str &= 95;
++str; ++str;
} }
return (orig_str); return (o_str);
} }
/* //// /* ////

View File

@ -6,7 +6,7 @@
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */ /* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/19 11:27:43 by tischmid #+# #+# */ /* Created: 2023/03/19 11:27:43 by tischmid #+# #+# */
/* Updated: 2023/03/24 01:37:33 by tischmid ### ########.fr */ /* Updated: 2023/03/26 00:52:35 by tischmid ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -29,7 +29,7 @@ char *ft_strcapitalize(char *str)
if (is_alpha) if (is_alpha)
*str &= 95; *str &= 95;
} }
else if (inside_word && is_alpha) else if (inside_word && (is_alpha || is_numeric))
*str |= 32; *str |= 32;
else else
inside_word = 0; inside_word = 0;
@ -41,7 +41,7 @@ char *ft_strcapitalize(char *str)
/* //// /* ////
#include <stdio.h> #include <stdio.h>
#define STR "salut, com0123456789ment tu vas ? 42" \ #define STR "salut, com0123456789ment tu vas ? 42" \
"mots quarante-deux; cinquante+et+un" "mots quArAnAe-deux; cinquante+et+un"
int main(void) int main(void)
{ {