Skip to content

πŸ“œ A function that returns an allocated pointer to a line every time a next line is found until EOF :D

Notifications You must be signed in to change notification settings

42-Ikole/GetNextLine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 

Repository files navigation

GetNextLine

A function that allocates a line every time a next line is found until EOF :D

βœ… usage

Include the header in your program and then call like:

char	*line;
int	fd = open("somerandomfile.txt", "r");

while (get_next_line(fd, &line) > 0) {
  printf("%s\n", line);
  free(line);
  }

❗ note

  • get_next_line returns the amount of bytes read unless eof is reached in which case it returns 0 or an error occurred then -1 is returned

πŸ’€ code

prototype

int get_next_line(int fd, char **line);

About

πŸ“œ A function that returns an allocated pointer to a line every time a next line is found until EOF :D

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages