-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_main.c
72 lines (66 loc) · 1.83 KB
/
ft_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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gusgonza <gusgonza@student.42barcel> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/06 16:02:19 by gusgonza #+# #+# */
/* Updated: 2024/05/12 16:50:23 by gusgonza ### ########.fr */
/* */
/* ************************************************************************** */
#include "get_next_line.h"
#include <stdio.h>
int main(void)
{
int fd;
char *line;
fd = open("giant_line.txt", O_RDONLY);
//fd = 0;
line = get_next_line(fd);
printf("%s", line);
free(line);
/*while ((line = get_next_line(fd)) != NULL)
{
printf("%s\n", line);
free(line);
}**/
if (fd > 0)
close(fd);
return (0);
}
/*
#include "get_next_line.h"
#include <stdio.h>
#include <fcntl.h>
int main(int argc, char **argv)
{
int fd;
char *line;
int line_number;
int counter;
if (argc < 2)
{
fprintf(stderr, "Durete los argumentos\n");
return (1);
}
counter = 0;
while (++counter < argc)
{
fd = open(argv[counter], O_RDONLY);
line = get_next_line(fd);
line_number = 0;
printf("=================================\n");
printf("%s:\n", argv[counter]);
printf("=================================\n");
while (line)
{
printf("%d: %s\n", line_number++, line);
free(line);
line = get_next_line(fd);
}
close(fd);
}
return (0);
}
*/