Skip to content

Commit

Permalink
copied ft_strcapitalize.c in testing with main
Browse files Browse the repository at this point in the history
  • Loading branch information
baigalmaa-baatar committed Aug 11, 2021
1 parent 3c37751 commit e62d120
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 18 deletions.
Binary file modified projects/modules/C02_with_main/ex09/a.out
Binary file not shown.
59 changes: 46 additions & 13 deletions projects/modules/C02_with_main/ex09/ft_strcapitalize.c
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);
}
23 changes: 18 additions & 5 deletions projects/modules/C02_with_main/ex09/main.c
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);
}

0 comments on commit e62d120

Please sign in to comment.