-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_fillstring.c
42 lines (39 loc) · 1.4 KB
/
ft_fillstring.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
40
41
42
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_fillstring.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rkrief <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/21 14:33:44 by rkrief #+# #+# */
/* Updated: 2017/11/22 20:34:09 by rkrief ### ########.fr */
/* */
/* ************************************************************************** */
#include "fillit.h"
char *ft_fill(int squarelen)
{
int i;
char *stetris;
int clone;
int clone2;
i = 0;
clone2 = squarelen;
clone = squarelen;
stetris = (char*)malloc(sizeof(char) * (((squarelen + 1) *
(squarelen + 1) + 1)));
stetris[(squarelen * (squarelen + 1)) + 1] = '\0';
while (clone2--)
{
while (clone > 0)
{
stetris[i++] = '.';
clone--;
}
stetris[i++] = '\n';
clone = squarelen;
}
i = 1;
while (i < squarelen + 2)
stetris[squarelen * (squarelen + 1) + i++] = '\0';
return (stetris);
}