GithubHelp home page GithubHelp logo

hecmarti / get_next_line Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 408 KB

A recreation of a C function that alows to see the content of a file

Home Page: https://42.nauman.cc/2023/09/08/get-next-line-c-get-next-line/#:~:text=The%20get_next_line%20function%20is%20a,ft_strjoin%2C%20read_line%2C%20and%20create_substring.

C 100.00%
42 c gnl42

get_next_line's Introduction

Get Next Line

This is the README file for the "get_next_line" project.

Description

The "get_next_line" function is a function that reads a file line by line. It is a useful function to have when working with files that have a large amount of data or when you need to process data line by line.

Usage

To use the "get_next_line" function, you need to include the appropriate header file and call the function with the file descriptor and a pointer to a string where the line will be stored. The function will return 1 if a line was read successfully, 0 if the end of the file was reached, or -1 if an error occurred.

Here is an example of how to use the "get_next_line" function:

#include "get_next_line.h"

int main() {
    int fd = open("example.txt", O_RDONLY);
    char *line = NULL;
    int ret;

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

    if (ret == 0) {
        printf("End of file reached\n");
    } else {
        printf("An error occurred\n");
    }

    close(fd);
    return 0;
}

get_next_line's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.