-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
C Piscine C 02 - OK 87% (2019-12-03)
- Loading branch information
Amanda Puchille pinha
committed
Dec 9, 2019
1 parent
a066c46
commit c60bc2c
Showing
33 changed files
with
547 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_strcpy.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: apuchill <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/11/28 14:44:32 by apuchill #+# #+# */ | ||
/* Updated: 2019/11/28 14:44:34 by apuchill ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
char *ft_strcpy(char *dest, char *src) | ||
{ | ||
int c; | ||
|
||
c = 0; | ||
while (src[c] != '\0') | ||
{ | ||
dest[c] = src[c]; | ||
c++; | ||
} | ||
dest[c] = '\0'; | ||
return (dest); | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <stdio.h> | ||
|
||
char *ft_strcpy(char *dest, char *src); | ||
|
||
int main(void) | ||
{ | ||
char source[] = "Source string."; | ||
char destin[] = "Destination string."; | ||
char *dest; | ||
|
||
printf("BEFORE\n\tsrc: %s\n\tdes: %s\n", source, destin); | ||
|
||
dest = ft_strcpy(destin, source); | ||
|
||
printf("AFTER\n\tsrc: %s\n\tdes: %s\n", source, dest); | ||
return (0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_strncpy.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: apuchill <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/11/28 15:01:11 by apuchill #+# #+# */ | ||
/* Updated: 2019/12/02 23:15:10 by apuchill ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
char *ft_strncpy(char *dest, char *src, unsigned int n) | ||
{ | ||
unsigned int c; | ||
|
||
c = 0; | ||
while ((src[c] != '\0') && (c < n)) | ||
{ | ||
dest[c] = src[c]; | ||
c++; | ||
} | ||
while (c < n) | ||
{ | ||
dest[c] = '\0'; | ||
c++; | ||
} | ||
return (dest); | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include <stdio.h> | ||
|
||
char *ft_strncpy(char *dest, char *src, unsigned int n); | ||
|
||
int main(void) | ||
{ | ||
char src[] = "Source string."; | ||
char dest[] = "Destination string."; | ||
unsigned int n; | ||
|
||
n = 2; | ||
|
||
printf("BEFORE\n\tsrc: %s\n\tdes: %s\n", src, dest); | ||
|
||
ft_strncpy(dest, src, n); | ||
|
||
printf("AFTER\n\tsrc: %s\n\tdes: %s\n", src, dest); | ||
return (0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_str_is_alpha.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: apuchill <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/11/28 15:24:17 by apuchill #+# #+# */ | ||
/* Updated: 2019/11/28 15:24:19 by apuchill ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
int ft_str_is_alpha(char *str) | ||
{ | ||
int c; | ||
|
||
c = 0; | ||
while (str[c] != '\0') | ||
{ | ||
if ((str[c] < 'A') || (str[c] > 'Z' && str[c] < 'a') || (str[c] > 'z')) | ||
return (0); | ||
c++; | ||
} | ||
return (1); | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include <stdio.h> | ||
|
||
int ft_str_is_alpha(char *str); | ||
|
||
int main(void) | ||
{ | ||
char alpha[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; | ||
char *p_alp; | ||
p_alp = alpha; | ||
|
||
char special[] = "ABC abc áéíóú àèìòù âêîôû äëïöü \'\"(){}[]!?@#$&* wxyz WXYZ"; | ||
char *p_spe; | ||
p_spe = special; | ||
|
||
char empty[] = ""; | ||
char *p_emp; | ||
p_emp = empty; | ||
|
||
printf("-----\n1 = String contains only alphabetical chars\n0 = String doesn't contain only alphabetical chars\n\n"); | ||
printf("%s = %d\n", alpha, ft_str_is_alpha(p_alp)); | ||
printf("%s = %d\n", special, ft_str_is_alpha(p_spe)); | ||
printf("Empty = %d\n-----\n", ft_str_is_alpha(p_emp)); | ||
|
||
return (0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_str_is_numeric.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: apuchill <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/11/28 19:30:48 by apuchill #+# #+# */ | ||
/* Updated: 2019/11/28 19:30:51 by apuchill ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
int ft_str_is_numeric(char *str) | ||
{ | ||
int c; | ||
|
||
c = 0; | ||
while (str[c] != '\0') | ||
{ | ||
if ((str[c] < '0') || (str[c] > '9')) | ||
return (0); | ||
c++; | ||
} | ||
return (1); | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include <stdio.h> | ||
|
||
int ft_str_is_numeric(char *str); | ||
|
||
int main(void) | ||
{ | ||
char numeric[] = "0123456789"; | ||
char *p_num; | ||
p_num = numeric; | ||
|
||
char special[] = "0123456789_"; | ||
char *p_spe; | ||
p_spe = special; | ||
|
||
char empty[] = ""; | ||
char *p_emp; | ||
p_emp = empty; | ||
|
||
printf("-----\n1 = String contains only numerical chars\n0 = String doesn't contain only numerical chars\n\n"); | ||
printf("%s = %d\n", numeric, ft_str_is_numeric(p_num)); | ||
printf("%s = %d\n", special, ft_str_is_numeric(p_spe)); | ||
printf("Empty = %d\n-----\n", ft_str_is_numeric(p_emp)); | ||
|
||
return (0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_str_is_lowercase.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: apuchill <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/11/28 19:41:09 by apuchill #+# #+# */ | ||
/* Updated: 2019/11/28 19:41:11 by apuchill ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
int ft_str_is_lowercase(char *str) | ||
{ | ||
int c; | ||
|
||
c = 0; | ||
while (str[c] != '\0') | ||
{ | ||
if ((str[c] < 'a') || (str[c] > 'z')) | ||
return (0); | ||
c++; | ||
} | ||
return (1); | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include <stdio.h> | ||
|
||
int ft_str_is_lowercase(char *str); | ||
|
||
int main(void) | ||
{ | ||
char lowercase[] = "abcdefghijklmnopqrstuvwxyz"; | ||
char *p_lwr; | ||
p_lwr = lowercase; | ||
|
||
char special[] = "abcdefghijklmnopqrstuvwxyz_"; | ||
char *p_spe; | ||
p_spe = special; | ||
|
||
char empty[] = ""; | ||
char *p_emp; | ||
p_emp = empty; | ||
|
||
printf("-----\n1 = String contains only lowercase chars\n0 = String doesn't contain only lowercase chars\n\n"); | ||
printf("%s = %d\n", lowercase, ft_str_is_lowercase(p_lwr)); | ||
printf("%s = %d\n", special, ft_str_is_lowercase(p_spe)); | ||
printf("Empty = %d\n-----\n", ft_str_is_lowercase(p_emp)); | ||
|
||
return (0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_str_is_uppercase.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: apuchill <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/11/28 21:06:15 by apuchill #+# #+# */ | ||
/* Updated: 2019/11/28 21:06:17 by apuchill ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
int ft_str_is_uppercase(char *str) | ||
{ | ||
int c; | ||
|
||
c = 0; | ||
while (str[c] != '\0') | ||
{ | ||
if ((str[c] < 'A') || (str[c] > 'Z')) | ||
return (0); | ||
c++; | ||
} | ||
return (1); | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include <stdio.h> | ||
|
||
int ft_str_is_uppercase(char *str); | ||
|
||
int main(void) | ||
{ | ||
char uppercase[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; | ||
char *p_upr; | ||
p_upr = uppercase; | ||
|
||
char special[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ_"; | ||
char *p_spe; | ||
p_spe = special; | ||
|
||
char empty[] = ""; | ||
char *p_emp; | ||
p_emp = empty; | ||
|
||
printf("-----\n1 = String contains only uppercase chars\n0 = String doesn't contain only uppercase chars\n\n"); | ||
printf("%s = %d\n", uppercase, ft_str_is_uppercase(p_upr)); | ||
printf("%s = %d\n", special, ft_str_is_uppercase(p_spe)); | ||
printf("Empty = %d\n-----\n", ft_str_is_uppercase(p_emp)); | ||
|
||
return (0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_str_is_printable.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: apuchill <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/11/28 21:09:24 by apuchill #+# #+# */ | ||
/* Updated: 2019/11/28 21:09:26 by apuchill ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
int ft_str_is_printable(char *str) | ||
{ | ||
int c; | ||
|
||
c = 0; | ||
while (str[c] != '\0') | ||
{ | ||
if ((str[c] < 32) || (str[c] > 126)) | ||
return (0); | ||
c++; | ||
} | ||
return (1); | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include <stdio.h> | ||
|
||
int ft_str_is_printable(char *str); | ||
|
||
int main(void) | ||
{ | ||
char string[] = "Normal characters string"; | ||
char *p_str; | ||
p_str = string; | ||
|
||
char unpr[] = "Unprintables: \t (tab), \a (?)"; | ||
char *p_unp; | ||
p_unp = unpr; | ||
|
||
char empty[] = ""; | ||
char *p_emp; | ||
p_emp = empty; | ||
|
||
printf("-----\n1 = Contains only printable characters\n0 = Contains unprintable characters\n\n"); | ||
printf("%s = %d\n", string, ft_str_is_printable(p_str)); | ||
printf("%s = %d\n", unpr, ft_str_is_printable(p_unp)); | ||
printf("Empty = %d\n-----\n", ft_str_is_printable(p_emp)); | ||
|
||
return (0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_strupcase.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: apuchill <[email protected]> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2019/11/28 21:17:59 by apuchill #+# #+# */ | ||
/* Updated: 2019/11/28 21:18:01 by apuchill ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
char *ft_strupcase(char *str) | ||
{ | ||
int c; | ||
|
||
c = 0; | ||
while (str[c] != '\0') | ||
{ | ||
if ((str[c] >= 'a') && (str[c] <= 'z')) | ||
str[c] -= 'a' - 'A'; | ||
c++; | ||
} | ||
return (str); | ||
} |
Binary file not shown.
Oops, something went wrong.