-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_b.c
More file actions
45 lines (42 loc) · 1.5 KB
/
main_b.c
File metadata and controls
45 lines (42 loc) · 1.5 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
42
43
44
45
/* ************************************************************************** */
/* */
/* :::::::: */
/* main_b.c :+: :+: */
/* +:+ */
/* By: anonymous <anonymous@student.codam.nl> +#+ */
/* +#+ */
/* Created: 2020/12/11 01:43:10 by anonymous #+# #+# */
/* Updated: 2020/12/11 01:43:10 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 main(int argc, char **argv)
{
int fd;
int fd2;
int ret;
char *line;
fd = open(argv[1], O_RDONLY);
fd2 = open("lines.txt", O_RDONLY);
if (fd == -1 || fd2 == -1)
{
printf("failed to open file \n");
return (-1);
}
ret = 1;
while (ret && argc)
{
ret = get_next_line(fd, &line);
printf("%d| line1 = %s\n", ret, line);
free(line);
ret = get_next_line(fd2, &line);
printf("%d| line1 = %s\n", ret, line);
free(line);
}
return (0);
}