-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathft_strrepl.c
executable file
·38 lines (34 loc) · 1.26 KB
/
ft_strrepl.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strrepl.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gab <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/03/12 16:02:19 by gab #+# #+# */
/* Updated: 2021/03/12 16:02:23 by gab ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdio.h>
char *ft_strrepl(char *str, char c1, char c2)
{
int i = 0;
char str1[100];
while (str[i])
{
if (str[i] == c1)
str1[i] = c2;
else
str1[i] = str[i];
i++;
}
str = str1;
return (str);
}
int main()
{
char *str = "Toto";
char c1 = 'o';
char c2 = 'a';
printf("%s\n", ft_strrepl(str, c1, c2));
}