-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
55 lines (52 loc) · 1.55 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
46
47
48
49
50
51
52
53
54
55
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* main.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kperreau <kperreau@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/11/10 17:56:05 by kperreau #+# #+# */
/* Updated: 2015/02/10 22:24:46 by kperreau ### ########.fr */
/* */
/* ************************************************************************** */
#include "get_next_line.h"
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include "libft.h"
int main(int argc, char **argv)
{
int fd;
char *line;
line = NULL;
if (argc > 1)
{
if (argc > 2 || (fd = open(argv[1], O_RDONLY)) != -1)
{
if (argc > 3)
printf("%d", get_next_line(23, &line));
else
{
if (argc > 2)
fd = 0;
while (get_next_line(fd, &line) == 1)
{
printf("%s", line);
memset(line, '*', strlen(line));
free(line);
line = NULL;
}
if (line)
{
printf("%s", line);
memset(line, '*', strlen(line));
free(line);
line = NULL;
}
close(fd);
}
}
}
return (0);
}