-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_read.c
executable file
·33 lines (30 loc) · 1.15 KB
/
ft_read.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_read.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ioleksiu <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/28 20:06:53 by ioleksiu #+# #+# */
/* Updated: 2017/01/30 17:47:09 by ioleksiu ### ########.fr */
/* */
/* ************************************************************************** */
#include "fillit.h"
char *ft_read(char *argv)
{
int fd;
int i;
char *str;
char c;
i = 0;
str = (char *)malloc(546);
fd = open(argv, O_RDONLY);
if (fd < 0)
ft_error();
while ((read(fd, &c, 1)) > 0)
str[i++] = c;
if (i > 546)
ft_error();
close(fd);
return (str);
}