ex07 pointers instead of array indexing

This commit is contained in:
Timo Schmidt 2023-03-24 01:23:30 +01:00
parent 7d0a05181c
commit acfc42ef00
1 changed files with 11 additions and 10 deletions

View File

@ -6,19 +6,22 @@
/* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */ /* By: tischmid <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/03/19 11:18:13 by tischmid #+# #+# */ /* Created: 2023/03/19 11:18:13 by tischmid #+# #+# */
/* Updated: 2023/03/21 09:33:54 by tischmid ### ########.fr */ /* Updated: 2023/03/24 01:22:44 by tischmid ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
char *ft_strlowcase(char *str) char *ft_strlowcase(char *str)
{ {
int i; char *orig_str;
i = -1; orig_str = str;
while (str[++i] != '\0') while (*str)
if (str[i] >= 'A' && str[i] <= 'Z') {
str[i] = str[i] | 32; if (*str >= 'A' && *str <= 'Z')
return (str); *str |= 32;
++str;
}
return (orig_str);
} }
/* //// /* ////
@ -27,10 +30,8 @@ char *ft_strlowcase(char *str)
int main(void) int main(void)
{ {
char s1[] = "hEllO worLd"; char s1[] = "hEllO worLd";
char *s2;
printf("%s\n", s1); printf("%s\n", s1);
s2 = ft_strlowcase(s1); printf("%s\n", ft_strlowcase(s1));
printf("%s\n", s2);
return (0); return (0);
} }
*/ //// */ ////