-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_create.c
executable file
·51 lines (46 loc) · 1.41 KB
/
ft_create.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
43
44
45
46
47
48
49
50
51
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_create.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mikim <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/03/16 05:00:51 by mikim #+# #+# */
/* Updated: 2019/03/02 21:45:50 by xinzhang ### ########.fr */
/* */
/* ************************************************************************** */
#include "fillit.h"
void ft_format_board(char **board, int size)
{
int i;
int j;
i = -1;
while (++i < size)
{
j = 0;
while (j < size)
{
board[i][j++] = '.';
}
}
}
char **ft_create_board(int size)
{
char **board;
int i;
int j;
i = 0;
j = 0;
if (!(board = (char**)malloc(sizeof(char*) * (size + 1))))
return (NULL);
board[size] = NULL;
while (i < size)
{
if (!(board[i] = (char*)malloc(sizeof(char*) * (size + 1))))
return (NULL);
board[i][size] = '\0';
i++;
}
ft_format_board(board, size);
return (board);
}