Compare commits

...

7 Commits

Author SHA1 Message Date
Timo Schmidt e6dc426c58 space after "while" keyword 2023-03-19 11:17:38 +01:00
Timo Schmidt e4e7d76fb6 ft_str_is_printable.c 2023-03-19 11:16:44 +01:00
Timo Schmidt 221d4c07ea ft_str_is_uppercase.c 2023-03-19 11:13:13 +01:00
Timo Schmidt 9e4854ade2 ft_str_is_alpha.c 2023-03-19 11:12:12 +01:00
Timo Schmidt 051459b33a ft_str_is_numeric.c 2023-03-19 11:12:10 +01:00
Timo Schmidt b68ced862c ft_str_is_lowercase.c 2023-03-19 11:12:08 +01:00
Timo Schmidt 3a3fb2e0e3 ft_strncpy.c 2023-03-19 10:32:01 +01:00
6 changed files with 210 additions and 0 deletions

40
ex01/ft_strncpy.c Normal file
View File

@ -0,0 +1,40 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strncpy.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/19 10:25:26 by tischmid #+# #+# */
/* Updated: 2023/03/19 10:33:04 by tischmid ### ########.fr */
/* */
/* ************************************************************************** */
char *ft_strncpy(char *dest, char *src, unsigned int n)
{
unsigned int i;
i = -1;
while (++i < n && src[i] != '\0')
{
dest[i] = src[i];
}
while (++i < n)
{
dest[i] = '\0';
}
return (dest);
}
/* ////
#include <stdio.h>
int main(void)
{
char s1[10];
ft_strncpy(s1, "Hello", 4);
printf("%s\n", s1);
return (0);
}
*/ ////

34
ex02/ft_str_is_alpha.c Normal file
View File

@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_alpha.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/19 10:33:26 by tischmid #+# #+# */
/* Updated: 2023/03/19 11:04:39 by tischmid ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_alpha(char *str)
{
int i;
i = 0;
while ((str[i] | 32) >= 'a' && (str[i] | 32) <= 'z')
{
++i;
}
return (str[i] == '\0');
}
/* ////
#include <stdio.h>
int main(void)
{
char s[] = "";
printf("%d\n", ft_str_is_alpha(s));
return (0);
}
*/ ////

34
ex03/ft_str_is_numeric.c Normal file
View File

@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_numeric.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/19 10:33:26 by tischmid #+# #+# */
/* Updated: 2023/03/19 11:04:24 by tischmid ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_numeric(char *str)
{
int i;
i = 0;
while (str[i] >= '0' && str[i] <= '9')
{
++i;
}
return (str[i] == '\0');
}
/* ////
#include <stdio.h>
int main(void)
{
char s[] = "";
printf("%d\n", ft_str_is_numeric(s));
return (0);
}
*/ ////

View File

@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_lowercase.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/19 11:03:56 by tischmid #+# #+# */
/* Updated: 2023/03/19 11:17:16 by tischmid ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_lowercase(char *str)
{
int i;
i = 0;
while (str[i] >= 'a' && str[i] <= 'z')
{
++i;
}
return (str[i] == '\0');
}
/* ////
#include <stdio.h>
int main(void)
{
char s[] = "abcdef";
printf("%d\n", ft_str_is_lowercase(s));
return (0);
}
*/ ////

View File

@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_uppercase.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/19 11:03:56 by tischmid #+# #+# */
/* Updated: 2023/03/19 11:17:00 by tischmid ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_uppercase(char *str)
{
int i;
i = 0;
while (str[i] >= 'A' && str[i] <= 'Z')
{
++i;
}
return (str[i] == '\0');
}
/* ////
#include <stdio.h>
int main(void)
{
char s[] = "ABCDEF";
printf("%d\n", ft_str_is_uppercase(s));
return (0);
}
*/ ////

View File

@ -0,0 +1,34 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_str_is_printable.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/19 11:03:56 by tischmid #+# #+# */
/* Updated: 2023/03/19 11:17:09 by tischmid ### ########.fr */
/* */
/* ************************************************************************** */
int ft_str_is_printable(char *str)
{
int i;
i = 0;
while (str[i] >= 32 && str[i] <= 126)
{
++i;
}
return (str[i] == '\0');
}
/* ////
#include <stdio.h>
int main(void)
{
char s[] = "A BCDEF ~~~ ";
printf("%d\n", ft_str_is_printable(s));
return (0);
}
*/ ////