Hunam6 / get_next_line

Indispensable utility to read a file - Hive Helsinki (42 school)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

get_next_line

Indispensable utility to read a file

🛠️ Installation

Compile your project with get_next_line.c and get_next_line_utils.c. Include get_next_line.h in your file.

📚 Usage

#include <stdio.h>
#include <fcntl.h>
#include "get_next_line.h"

int main(int ac, char **av)
{
	int fd;
	if (ac != 2)
		return(printf("Usage: ./gnl <file>\n"));
	if ((fd = open(av[1], O_RDONLY)) == -1)
		return (printf("Failed to open the file.\n"));
	while (42)
	{
		char *line = get_next_line(fd);
		if (!line)
			break;
		printf("%s", line);
	}
	if (close(fd) == -1)
		return (printf("Failed to close the file.\n"));
}

About

Indispensable utility to read a file - Hive Helsinki (42 school)

License:MIT License


Languages

Language:C 100.0%