-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_2d_char_array.c
More file actions
35 lines (32 loc) · 1.31 KB
/
ft_2d_char_array.c
File metadata and controls
35 lines (32 loc) · 1.31 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_2d_char_array.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sgrindhe <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/08/06 23:37:00 by sgrindhe #+# #+# */
/* Updated: 2018/08/08 21:45:27 by sgrindhe ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
char **ft_2d_char_array(unsigned int width, unsigned int height)
{
unsigned int i;
char **result;
if (width == 0 || height == 0)
return (NULL);
result = malloc(sizeof(char*) * (width + 1));
result[width] = NULL;
if (!result)
return (NULL);
i = 0;
while (i < height)
{
result[i] = (char*)malloc(sizeof(char) * (height + 1));
if (!result[i])
return (NULL);
result[i++][height] = '\0';
}
return (result);
}