Intro - Goal - Tecnology - Functionality - How to use - Tests - Update - Author
- This was my second project at école 42.
- It is an introduction to the concepts File descriptors, Static Variables and read() function.
- It is also the first project where I had to create a structure for my code.
- I used tests created by other people to guide me, find errors and leaks.
- The "_bonus" files have the same code of the files without "_bonus", the suffix is added to get the bonus evaluation.
- GNL goal is to create a function that will read a line of a File descriptor:
- Uses concepts learned on Libft project.
- Introduces new concepts of static variable and file descriptor.
- Language: C
- VS code
- WSL ubuntu
- Norminette 42 (code norm used by école 42)
- Remote SSH access to iMac for tests.
- Clone the repository
git clone https://github.com/GitFlaviobc/GNL.gitExample:
- Main function that will open and read the file
int main(int argc, char **argv)
{
int fd;
fd = ft_open_file(argv);
ft_read_file(fd);
return (0);
}- Function to open the file descriptor
int ft_open_file(char **argv)
{
int fd;
fd = open(argv[1], O_RDONLY);
if (fd < 0)
{
printf("Error.\nFile descriptor error.\n");
}
return (fd);
}- Use the GNL in a loop to read the File Descriptor
void ft_read_file(int fd)
{
char *read_line;
int reading;
reading = 1;
while (reading == 1)
{
reading = get_next_line(fd, &read_line);
free(read_line);
}
close(fd);
}- Inside this example, you can get the information from the file descriptor add some logic and use it.
- Note: I didn't created any of the test, I just used them to check my project. All credit goes to their creators.
- All tests were done on the browser connect with SSH to an iMac.
