项目作者: n-sance

项目描述 :
42 study project
高级语言: C
项目地址: git://github.com/n-sance/get_next_line.git
创建时间: 2019-09-12T09:03:53Z
项目社区:https://github.com/n-sance/get_next_line

开源协议:

下载


What’s that?

This projects is about creating a function that, allows to read a line ending with a newline character (‘\n’)
from a file descriptor, without knowing its size beforehand.
One of the goal of this project is to learn a highly interesting new concept in C programming:
static variables, and to gain a deeper understanding of allocations,
whether they happen on the stack memory or in the heap memory,
the manipulation and the life cycle of a buffer, the unexpected
complexity implied in the use of one or many static variables.

How can I use it?

First you need to compile it as following below:

Run the following commands:

To compile
make
To remove objects:
make clean
To remove objects and binary file (program):
make fclean
To re-compile:
make re

Then executing:

To test the function, compile with main.c.

gcc main.c src/get_next_line.c

./a.out tests/some_lines.txt

If wanted to test with multiple file descriptors, compile with main-multiple-fds.c

gcc main-multiple-fds.c src/get_next_line.c.

./a.out tests/some_lines.txt tests/nl_and_eof_one.txt