-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
45 lines (41 loc) · 1.37 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
41
42
43
44
45
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: agarijo- <agarijo-@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/03 17:23:45 by agarijo- #+# #+# */
/* Updated: 2023/03/01 07:05:46 by agarijo- ### ########.fr */
/* */
/* ************************************************************************** */
#include "get_next_line.h"
void leaks(void)
{
system("leaks -q --list a.out");
}
int main(void)
{
int fd;
int counter;
char *filename;
char *line;
counter = 0;
filename = "file.txt";
fd = open(filename, O_RDONLY);
if (fd == -1)
return (printf("ERROR\n"), -1);
line = get_next_line(fd);
while (line != NULL)
{
printf("################\n");
printf("%s", line);
printf("################\n");
free(line);
line = get_next_line(fd);
counter++;
}
close(fd);
free(line);
atexit(leaks);
}