-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
40 lines (37 loc) · 1.31 KB
/
main.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: pguthaus <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/18 14:56:37 by pguthaus #+# #+# */
/* Updated: 2019/11/21 16:34:37 by pguthaus ### ########.fr */
/* */
/* ************************************************************************** */
#include <fcntl.h>
#include <sys/types.h>
#include "get_next_line.h"
#include <stdio.h>
int main(int ac, char **av)
{
int fd;
int ret;
char *buff;
size_t line;
(void)ac;
buff = NULL;
if ((fd = open(av[1], O_RDONLY)) == -1)
return (-1);
line = 0;
while ((ret = get_next_line(fd, &buff)) >= 0)
{
line++;
printf("%4zu#%d %s\n", line, ret, buff);
free((void *)buff);
if (ret == 0)
break ;
}
while (1);
return (ret);
}