Too much
This commit is contained in:
parent
acfc42ef00
commit
baae624589
|
@ -6,7 +6,7 @@
|
|||
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/19 05:59:56 by tischmid #+# #+# */
|
||||
/* Updated: 2023/03/24 01:05:46 by tischmid ### ########.fr */
|
||||
/* Updated: 2023/03/24 01:29:58 by tischmid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -24,13 +24,21 @@ char *ft_strcpy(char *s1, char *s2)
|
|||
/* ////
|
||||
#include <stdio.h>
|
||||
#define BUFSIZE 10
|
||||
#define STR "||||||||||"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char s1[BUFSIZE];
|
||||
int arrlen = 4;
|
||||
char *teststrings[] = {"", "h", "he", "hey"};
|
||||
char buf[BUFSIZE] = STR;
|
||||
|
||||
ft_strcpy(s1, "0123456789");
|
||||
printf("%s\n", s1);
|
||||
for (int j = 0; j < arrlen; ++j)
|
||||
{
|
||||
printf("####### Element == '%s' #######\n", teststrings[j]);
|
||||
ft_strcpy(buf, teststrings[j]);
|
||||
for (int i = 0; i < BUFSIZE; ++i)
|
||||
printf((buf[i] >= 32 && buf[i] <= 126) ? "%c\n" : "0x%x\n", buf[i]);
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
*/ ////
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/19 10:25:26 by tischmid #+# #+# */
|
||||
/* Updated: 2023/03/24 01:05:10 by tischmid ### ########.fr */
|
||||
/* Updated: 2023/03/24 01:29:37 by tischmid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -23,11 +23,11 @@ char *ft_strncpy(char *dest, char *src, unsigned int n)
|
|||
/* ////
|
||||
#include <stdio.h>
|
||||
#define BUFSIZE 10
|
||||
|
||||
#define STR "||||||||||"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char buf[BUFSIZE] = "||||||||||";
|
||||
char buf[BUFSIZE] = STR;
|
||||
|
||||
for (int j = 0; j < 11; ++j)
|
||||
{
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/19 10:33:26 by tischmid #+# #+# */
|
||||
/* Updated: 2023/03/19 11:04:39 by tischmid ### ########.fr */
|
||||
/* Updated: 2023/03/24 01:29:19 by tischmid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -24,11 +24,14 @@ int ft_str_is_alpha(char *str)
|
|||
|
||||
/* ////
|
||||
#include <stdio.h>
|
||||
#define STR "aa"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char s[] = "";
|
||||
printf("%d\n", ft_str_is_alpha(s));
|
||||
if (ft_str_is_alpha(STR))
|
||||
printf("Contains only alphabetical characters\n");
|
||||
else
|
||||
printf("Contains non-alphabetical characters\n");
|
||||
return (0);
|
||||
}
|
||||
*/ ////
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/19 10:33:26 by tischmid #+# #+# */
|
||||
/* Updated: 2023/03/19 11:04:24 by tischmid ### ########.fr */
|
||||
/* Updated: 2023/03/24 01:29:01 by tischmid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -24,11 +24,14 @@ int ft_str_is_numeric(char *str)
|
|||
|
||||
/* ////
|
||||
#include <stdio.h>
|
||||
#define STR "0123456789"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char s[] = "";
|
||||
printf("%d\n", ft_str_is_numeric(s));
|
||||
if (ft_str_is_numeric(STR))
|
||||
printf("Is numeric\n");
|
||||
else
|
||||
printf("Is not numeric\n");
|
||||
return (0);
|
||||
}
|
||||
*/ ////
|
||||
|
|
|
@ -6,29 +6,27 @@
|
|||
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/19 11:03:56 by tischmid #+# #+# */
|
||||
/* Updated: 2023/03/19 11:17:16 by tischmid ### ########.fr */
|
||||
/* Updated: 2023/03/24 01:08:55 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');
|
||||
while (*str >= 'a' && *str <= 'z')
|
||||
++str;
|
||||
return (!*str);
|
||||
}
|
||||
|
||||
/* ////
|
||||
#include <stdio.h>
|
||||
#define STR "abcd"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char s[] = "abcdef";
|
||||
printf("%d\n", ft_str_is_lowercase(s));
|
||||
if (ft_str_is_lowercase(STR))
|
||||
printf("Is all lowercase\n");
|
||||
else
|
||||
printf("Contains non-lowercase characters\n");
|
||||
return (0);
|
||||
}
|
||||
*/ ////
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/19 11:03:56 by tischmid #+# #+# */
|
||||
/* Updated: 2023/03/19 11:17:00 by tischmid ### ########.fr */
|
||||
/* Updated: 2023/03/24 01:16:08 by tischmid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -24,11 +24,14 @@ int ft_str_is_uppercase(char *str)
|
|||
|
||||
/* ////
|
||||
#include <stdio.h>
|
||||
#define STR "ABCDEf"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char s[] = "ABCDEF";
|
||||
printf("%d\n", ft_str_is_uppercase(s));
|
||||
if (ft_str_is_uppercase(STR))
|
||||
printf("Is all uppercase\n");
|
||||
else
|
||||
printf("Contains non-uppercase characters\n");
|
||||
return (0);
|
||||
}
|
||||
*/ ////
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/19 11:03:56 by tischmid #+# #+# */
|
||||
/* Updated: 2023/03/22 20:27:43 by tischmid ### ########.fr */
|
||||
/* Updated: 2023/03/24 01:16:50 by tischmid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -24,11 +24,14 @@ int ft_str_is_printable(char *str)
|
|||
|
||||
/* ////
|
||||
#include <stdio.h>
|
||||
#define STR "BCDEF ~~~ "
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char s[] = "A BCDEF ~~~ ";
|
||||
printf("%d\n", ft_str_is_printable(s));
|
||||
if (ft_str_is_printable(STR))
|
||||
printf("Is printable\n");
|
||||
else
|
||||
printf("Is not printable\n");
|
||||
return (0);
|
||||
}
|
||||
*/ ////
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/19 11:18:13 by tischmid #+# #+# */
|
||||
/* Updated: 2023/03/24 01:22:57 by tischmid ### ########.fr */
|
||||
/* Updated: 2023/03/24 01:28:23 by tischmid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -26,10 +26,11 @@ char *ft_strupcase(char *str)
|
|||
|
||||
/* ////
|
||||
#include <stdio.h>
|
||||
#define STR "hello world"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char s1[] = "hello world";
|
||||
char s1[] = STR;
|
||||
printf("%s\n", s1);
|
||||
printf("%s\n", ft_strupcase(s1));
|
||||
return (0);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/19 11:18:13 by tischmid #+# #+# */
|
||||
/* Updated: 2023/03/24 01:22:44 by tischmid ### ########.fr */
|
||||
/* Updated: 2023/03/24 01:28:12 by tischmid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
|
@ -26,10 +26,11 @@ char *ft_strlowcase(char *str)
|
|||
|
||||
/* ////
|
||||
#include <stdio.h>
|
||||
#define STR "hEllO worLd"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char s1[] = "hEllO worLd";
|
||||
char s1[] = STR;
|
||||
printf("%s\n", s1);
|
||||
printf("%s\n", ft_strlowcase(s1));
|
||||
return (0);
|
||||
|
|
|
@ -6,48 +6,46 @@
|
|||
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/19 11:27:43 by tischmid #+# #+# */
|
||||
/* Updated: 2023/03/24 00:34:07 by tischmid ### ########.fr */
|
||||
/* Updated: 2023/03/24 01:27:57 by tischmid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
char *ft_strcapitalize(char *str)
|
||||
{
|
||||
int i;
|
||||
int inside_word;
|
||||
int is_alpha;
|
||||
int is_numeric;
|
||||
char c;
|
||||
char *orig_str;
|
||||
|
||||
orig_str = str;
|
||||
inside_word = 0;
|
||||
i = -1;
|
||||
while (str[++i] != '\0')
|
||||
while (*str)
|
||||
{
|
||||
c = str[i];
|
||||
is_alpha = ((c | 32) >= 'a' && (c | 32) <= 'z');
|
||||
is_numeric = (c >= '0' && c <= '9');
|
||||
is_alpha = ((*str | 32) >= 'a' && (*str | 32) <= 'z');
|
||||
is_numeric = (*str >= '0' && *str <= '9');
|
||||
if (!inside_word && (is_alpha || is_numeric))
|
||||
{
|
||||
inside_word = 1;
|
||||
if (is_alpha)
|
||||
str[i] = str[i] & 95;
|
||||
*str &= 95;
|
||||
}
|
||||
else if (inside_word && (is_alpha || is_numeric))
|
||||
str[i] = str[i] | 32;
|
||||
else if (inside_word && is_alpha)
|
||||
*str |= 32;
|
||||
else
|
||||
inside_word = 0;
|
||||
++str;
|
||||
}
|
||||
return (str);
|
||||
return (orig_str);
|
||||
}
|
||||
|
||||
/* ////
|
||||
#include <stdio.h>
|
||||
#define STR "salut, com0123456789ment tu vas ? 42mots quarante-deux; cinquante+et+un"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char s1[] = "salut, comment tu vas ? 42mots quarante-deux; cinquante+et+un";
|
||||
char *s2;
|
||||
s2 = ft_strcapitalize(s1);
|
||||
printf("%s\n", s2);
|
||||
char s1[] = STR;
|
||||
printf("%s\n", ft_strcapitalize(s1));
|
||||
return (0);
|
||||
}
|
||||
*/ ////
|
||||
|
|
|
@ -6,48 +6,41 @@
|
|||
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2023/03/21 02:59:50 by tischmid #+# #+# */
|
||||
/* Updated: 2023/03/21 03:10:35 by tischmid ### ########.fr */
|
||||
/* Updated: 2023/03/24 01:04:50 by tischmid ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include <unistd.h>
|
||||
#define HEX_ALPH "0123456789abcdef"
|
||||
|
||||
void ft_putstr_non_printable(char *str)
|
||||
{
|
||||
char first_digit;
|
||||
char second_digit;
|
||||
|
||||
while (*str)
|
||||
{
|
||||
if (*str < 32)
|
||||
{
|
||||
first_digit = "0123456789abcdef"[*str / 16];
|
||||
second_digit = "0123456789abcdef"[*str % 16];
|
||||
write(1, "\\", 1);
|
||||
write(1, &first_digit, 1);
|
||||
write(1, &second_digit, 1);
|
||||
write(1, &HEX_ALPH[*(unsigned char *) str / 16], 1);
|
||||
write(1, &HEX_ALPH[*(unsigned char *) str % 16], 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
write(1, str, 1);
|
||||
}
|
||||
++str;
|
||||
}
|
||||
}
|
||||
|
||||
/* ////
|
||||
#include <stdio.h>
|
||||
#define BUFSIZE 256
|
||||
|
||||
int main(void)
|
||||
{
|
||||
char s1[200];
|
||||
int i;
|
||||
char s1[BUFSIZE];
|
||||
|
||||
for (i = 0; i < 127; ++i)
|
||||
for (int i = -128; i < 127; ++i)
|
||||
{
|
||||
s1[i] = i + 1;
|
||||
s1[i + 128] = i ? i : 1;
|
||||
}
|
||||
s1[i] = 0;
|
||||
ft_putstr_non_printable(s1);
|
||||
return (0);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue