-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_make_s.c
39 lines (36 loc) · 1.19 KB
/
ft_make_s.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
39
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_make_zs.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ohachim <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/03/04 14:15:25 by ohachim #+# #+# */
/* Updated: 2019/05/26 06:14:58 by ohachim ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char *ft_make_s(int len, char fill)
{
char *str;
int cn;
cn = 0;
if (len <= 0)
{
if (!(str = ft_strnew(1)))
return (NULL);
return (str);
}
else
{
if (!(str = ft_strnew(len + 1)))
return (NULL);
}
while (cn < len)
{
str[cn] = fill;
cn++;
}
str[cn] = '\0';
return (str);
}