-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
50 lines (47 loc) · 891 Bytes
/
main.c
File metadata and controls
50 lines (47 loc) · 891 Bytes
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
46
47
48
49
50
#include "get_next_line.h"
int main(void)
{
int fd = open("cancion.txt", O_RDONLY);
if (fd == -1)
{
perror("Error al abrir el archivo");
return 1;
}
char *line;
while ((line = get_next_line(fd)) != NULL)
{
printf("%s", line);
free(line);
}
close(fd);
return 0;
}
/*int main(void)
{
char *line;
int i;
int fd1;
int fd2;
int fd3;
fd1 = open("get_next_line_bonus.c", O_RDONLY);
fd2 = open("get_next_line_utils_bonus.c", O_RDONLY);
fd3 = open("get_next_line.h", O_RDONLY);
i = 1;
while (i < 100)
{
line = get_next_line(fd1);
printf("line [%02d]: %s", i, line);
free(line);
line = get_next_line(fd2);
printf("line [%02d]: %s", i, line);
free(line);
line = get_next_line(fd3);
printf("line [%02d]: %s", i, line);
free(line);
i++;
}
close(fd1);
close(fd2);
close(fd3);
return (0);
}*/