Skip to content

GNL - Get Next Line: A project from école 42 introducing file descriptors, static variables, and the read() function. Written in C using VS code and WSL Ubuntu. The goal is to read a line from a file descriptor. Functions follow a structured approach.

License

GitFlaviobc/GNL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

GNL - Get Next Line

📋 Table of contents

Intro - Goal - Tecnology - Functionality - How to use - Tests - Update - Author

Intro

  • 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.

📋

🎯 Goal

  • 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.

📋

🛠️ Tecnology

  • Language: C
  • VS code
  • WSL ubuntu
  • Norminette 42 (code norm used by école 42)
  • Remote SSH access to iMac for tests.

📋

📚 Functionality

Flow Chart

📋

📖 How to use

  • Clone the repository
git clone https://github.com/GitFlaviobc/GNL.git

Example:

  • 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.

📋

👨‍💻 Tests

*42 changes the projects from time to time, and the test keep being updated to follow it. So this project may be outdated for the tests.

📋

🆙 Updates

⚠️🚧

📋

😀 Author

Name: Flávio Bonini Campos

Linkedin

📋

About

GNL - Get Next Line: A project from école 42 introducing file descriptors, static variables, and the read() function. Written in C using VS code and WSL Ubuntu. The goal is to read a line from a file descriptor. Functions follow a structured approach.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages