About • How to use • Mandatory • Bonus • Norminette • Contributing • License
This project taught me how to read from a file descriptor and use static variables. This function retrieves a single line from a specified file descriptor. When called in a loop, get_next_line returns all the contents of the file, one line at a time until the end of the file is reached. Additionally, this function can be compiled with any buffer size specified.
- Subject
PDF
- References
GitHub
git clone git@github.com:jotavare/get_next_line.git
cd get_next_line/get_next_line
The program should always be compiled with the flags below.
[Flags] -Wall -Wextra -Werror
[Mandatory] cc [Flags] main.c get_next_line.c get_next_line_utils.c
[Bonus] cc [Flags] main.c get_next_line_bonus.c get_next_line_utils_bonus.c
get_next_line should be able to compile with and without the -D BUFFER_SIZE=[SIZE] flag.
[Flags] -Wall -Wextra -Werror -D BUFFER_SIZE=[SIZE]
[Mandatory] cc [Flags] main.c get_next_line.c get_next_line_utils.c
[Bonus] cc [Flags] main.c get_next_line_bonus.c get_next_line_utils_bonus.c
./a.out [text.txt]
./a.out [text1.txt] [text2.txt]
- Read from one file descriptor, one line at a time.
- Needs to return the line that was read. If empty or error, return
NULL
. - Should work as expected reading from a file or standard input.
- Returned line should include the terminating
\n
character, except if it's the end of the file and the line does not end with\n
. - The
get_next_line.h
header file should include at least theget_next_line()
function. - All adicional functions should be included in
get_next_line_utils.c
file, libft is not allowed. - To define the buffer size for
read()
, add the option to the compiled file-D BUFFER_SIZE=[SIZE]
.
- Use only one static variable.
- Manage multiple file descriptors at the same time.
- Bonus files should include a suffix
_bonus.[c/h]
.
At 42 School, it is expected that almost every project is written following the Norm, which is the coding standard of the school.
- No for, do...while, switch, case, goto, ternary operators, or variable-length arrays allowed;
- Each function must be a maximum of 25 lines, not counting the function's curly brackets;
- Each line must be at most 80 columns wide, with comments included;
- A function can take 4 named parameters maximum;
- No assigns and declarations in the same line (unless static);
- You can't declare more than 5 variables per function;
- ...
- 42 Norms - Information about 42 code norms.
PDF
- Norminette - Tool to respect the code norm, made by 42.
GitHub
- 42 Header - 42 header for Vim.
GitHub
If you find any issues or have suggestions for improvements, feel free to fork the repository and open an issue or submit a pull request.
This project is available under the MIT License. For further details, please refer to the LICENSE file.