-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
copied ft_strcapitalize.c in testing with main
- Loading branch information
1 parent
3c37751
commit e62d120
Showing
3 changed files
with
64 additions
and
18 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,17 +1,50 @@ | ||
#include <stdio.h> | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_strcapitalize.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: bbaatar <marvin@42.fr> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2021/02/09 13:38:48 by bbaatar #+# #+# */ | ||
/* Updated: 2021/08/11 14:40:03 by bbaatar ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
char *ft_strcapitalize(char *str) | ||
char *lowercase(char *str) | ||
{ | ||
int i; | ||
i = 0; | ||
int i; | ||
|
||
while(str[i] != '\0') | ||
{ | ||
if((str[i]>='A' && str[i]<='Z')) | ||
{ | ||
str[i] = str[i] + 32; | ||
} | ||
i++; | ||
} | ||
return(str); | ||
i = 0; | ||
while (str[i]) | ||
{ | ||
if (str[i] >= 'A' && str[i] <= 'Z') | ||
{ | ||
str[i] = str[i] + 32; | ||
} | ||
i++; | ||
} | ||
return (str); | ||
} | ||
|
||
char *ft_strcapitalize(char *str) | ||
{ | ||
int i; | ||
|
||
i = 0; | ||
str = lowercase(str); | ||
while (str[i]) | ||
{ | ||
if (!((str[i] >= 'a' && str[i] <= 'z'))) | ||
{ | ||
while (!((str[i] >= 'a' && str[i] <= 'z') | ||
|| (str[i] >= '0' && str[i] <= '9')) && str[i]) | ||
i++; | ||
if (str[i] >= 'a' && str[i] <= 'z') | ||
str[i] = str[i] - 32; | ||
} | ||
i++; | ||
} | ||
if (str[0] >= 'a' && str[0] <= 'z') | ||
str[0] = str[0] - 32; | ||
return (str); | ||
} |
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 |
---|---|---|
@@ -1,12 +1,25 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* main.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: bbaatar <marvin@42.fr> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2021/08/11 14:42:35 by bbaatar #+# #+# */ | ||
/* Updated: 2021/08/11 14:42:42 by bbaatar ### ########.fr */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include <stdio.h> | ||
|
||
char *ft_strcapitalize(char *str); | ||
char *ft_strcapitalize(char *str); | ||
|
||
int main(void) | ||
int main(void) | ||
{ | ||
char str[] = "LOLOLaaa"; | ||
|
||
printf(" %s", ft_strcapitalize(str)); | ||
char str1[] = "LOLOLaaa"; | ||
char str2[] = "salut, comment tu vas ? 42mots quarante-deux; cinquante+et+un"; | ||
|
||
printf ("%s\n", ft_strcapitalize(str1)); | ||
printf ("%s\n", ft_strcapitalize(str2)); | ||
return (0); | ||
} |