-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_strjoinc.c
37 lines (34 loc) · 1.19 KB
/
ft_strjoinc.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_strjoinc.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ecarvalh <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/22 17:13:28 by ecarvalh #+# #+# */
/* Updated: 2024/04/18 20:34:33 by ecarvalh ### ########.fr */
/* */
/* ************************************************************************** */
#include "minitalk.h"
char *ft_strjoinc(char *str, char c)
{
char *res;
int i;
if (!str)
{
str = (char *)malloc(1);
*str = 0;
}
res = (char *)malloc(ft_strlen(str) + 2);
if (!res)
return (NULL);
i = 0;
while (str[i])
{
res[i] = str[i];
i++;
}
res[i++] = c;
res[i] = 0;
return (free(str), res);
}