blob: b6595e0209063b489256a5ef39ebdcfcea6fac99 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdlib.h>
int get_next_line(int fd, char **line);
int main(int argc, char **argv)
{
int fd;
char *line;
fd = open(argv[1], O_RDONLY);
for (int i = 0; get_next_line(fd, &line) == 1; i++)
{
printf("%d [%s]\n", i, line);
free(line);
}
printf("$ [%s]\n", line);
free(line);
return 0;
}
|