-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
41 lines (38 loc) · 1.38 KB
/
main.c
File metadata and controls
41 lines (38 loc) · 1.38 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
36
37
38
39
40
41
/* ************************************************************************** */
/* */
/* :::::::: */
/* main.c :+: :+: */
/* +:+ */
/* By: anonymous <anonymous@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2020/12/11 01:42:41 by anonymous #+# #+# */
/* Updated: 2020/12/11 01:42:41 by anonymous ######## odam.nl */
/* */
/* ************************************************************************** */
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include "get_next_line.h"
int get_next_line(int fd, char **line);
int main(int argc, char **argv)
{
int fd;
char *line;
int ret;
fd = open(argv[1], O_RDONLY);
if (fd == -1)
{
printf("failed to open file \n");
return (0);
}
ret = 1;
while (ret && argc)
{
ret = get_next_line(fd, &line);
printf(" %d | %s\n", ret, line);
free(line);
}
return (0);
}