-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path6_test_only_nl.c
44 lines (41 loc) · 1.34 KB
/
6_test_only_nl.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* 6_test_only_nl.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mzolotar <mzolotar@student.42madrid.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/03 11:51:28 by mzolotar #+# #+# */
/* Updated: 2024/10/05 10:59:00 by mzolotar ### ########.fr */
/* */
/* ************************************************************************** */
#include "gnl_test.h"
void test_only_nl(void)
{
int fd;
char *line;
fd = open("6_only_nl.txt", O_RDONLY);
// Manejo de errores al abrir
if (fd == -1)
{
perror("Error al abrir el archivo");
return ;
}
while (1)
{
line = get_next_line(fd);
if (line == NULL)
break ;
printf("%s", line);
free(line);
line = NULL;
}
printf("\n");
// Manejo de errores al cerrar
if (close(fd) == -1)
{
perror("Error al cerrar el archivo");
return ;
}
return;
}