Coder Social home page Coder Social logo

jmatheis00 / 42_getnextline Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 14 KB

A custom C function that reads lines from file descriptors or standard input, providing a convenient method for handling input in C programs, including file reading and command-line interaction.

C 100.00%
42cursus 42projects 42school c getnextline read-from-file

42_getnextline's Introduction

42_getnextline

This project involves the creation of a custom C function called get_next_line() designed to read lines from a given file descriptor or standard input. This function will read and return lines one at a time, retaining the newline character as part of the line unless the end of the file is encountered without a newline. The goal of this project is to provide a useful way to handle input in C programs, covering both reading files and interacting via the command line.

The recoded getnextline function is called get_next_line() and has the following prototype:

char *get_next_line(int fd);

Usage

  1. Clone this repository and cd into it:
git clone https://github.com/jmatheis00/42_getnextline.git && cd 42_getnextline

Don't forget to add a file to be read!

Mandatory part

  1. Uncomment the main function in get_next_line.c or add your own main.c file with header get_next_line.h and a file to be read.
  2. Compile your code with the following command and replace <size> with the desired buffer size:
gcc -Wall -Werror -Wextra -D BUFFER_SIZE=<size> get_next_line.c get_next_line_utils.c && ./a.out

Bonus part

In the Bonus part, the get_next_line() function can manage multiple file descriptors at the same time.

  1. Uncomment the main function in get_next_line_bonus.c file or add your own main.c file with header get_next_line_bonus.h and files to be read.
  2. Compile your code with the following command and replace <size> with the desired buffer size:
gcc -Wall -Werror -Wextra -D BUFFER_SIZE=<size> get_next_line_bonus.c get_next_line_utils_bonus.c && ./a.out

42_getnextline's People

Contributors

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