This proyect is about a function that returns a line
read from a file descriptor (fd). Everytime we give a call, the function return a new line, until we reach the end of the text. Every string is null terminated.
As soon that we don't have more text inside the fd, our function will return ('NULL') , and the program ends.
Allowed functions : malloc
, open
, read
, free
.
If you dont know how to use open() and read() functions, there is an easy guide for you.
A file descriptor is an int variable that uniquely identifies an open file.
int Value | output | Description |
---|---|---|
0 | stdin | Fd used when reading user input from the terminal. |
1 | stdout | Fd used when writing to the terminal. |
2 | stderr | Fd used when writing an error to the terminal, a program which logs errors to a file. |
Static variables are really important, they have the property of preserving their value even after they are out of their scope, preserves its previous value in its previous scope and is not initialized again.
A static int variable remains in memory while the program is running.