-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_craadd.c
34 lines (31 loc) · 1.17 KB
/
ft_craadd.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_craadd.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ohachim <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/10/20 16:08:52 by ohachim #+# #+# */
/* Updated: 2018/10/20 16:19:38 by ohachim ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_craadd(char *s, char c)
{
char *dups;
int cn;
size_t len;
if (s == NULL)
return (NULL);
cn = 0;
len = ft_strlen(s) + 1;
dups = (char*)malloc(len + 1);
dups[cn] = c;
while (s[cn] != '\0')
{
dups[cn + 1] = s[cn];
cn++;
}
dups[cn + 1] = '\0';
return (dups);
}