GithubHelp home page GithubHelp logo

42porto_libft's Introduction

42porto printf

Libft

Your very first own library

This project is about coding a C library. It will contain a lot of general-purpose functions your programs will rely upon.

Table of Contents

Introduction

C programming can be very tedious when one doesn’t have access to the highly useful standard functions. This project is about understanding the way these functions work, implementing, and learning to use them. You will create your own library. It will be helpful since you will use it in your next C school assignments. Take the time to expand your libft throughout the year. However, when working on a new project, don’t forget to ensure the functions used in your library are allowed in the project guidelines.

Common Instructions

  • Your project must be written in C.
  • Your project must be written in accordance with the Norm. If you have bonus files/functions, they are included in the norm check and you will receive a 0 if there is a norm error inside.
  • Your functions should not quit unexpectedly (segmentation fault, bus error, double free, etc) apart from undefined behaviors. If this happens, your project will be considered non-functional and will receive a 0 during the evaluation.
  • All heap allocated memory space must be properly freed when necessary. No leaks will be tolerated.
  • If the subject requires it, you must submit a Makefile which will compile your source files to the required output with the flags -Wall, -Wextra and -Werror, use cc, and your Makefile must not relink.
  • Your Makefile must at least contain the rules $(NAME), all, clean, fclean, and re.
  • To turn in bonuses to your project, you must include a rule bonus to your Makefile, which will add all the various headers, libraries, or functions that are forbidden on the main part of the project. Bonuses must be in a different file _bonus.{c/h} if the subject does not specify anything else. Mandatory and bonus part evaluation is done separately.
  • If your project allows you to use your libft, you must copy its sources and its associated Makefile in a libft folder with its associated Makefile. Your project’s Makefile must compile the library by using its Makefile, then compile the project.
  • We encourage you to create test programs for your project even though this work won’t have to be submitted and won’t be graded. It will give you a chance to easily test your work and your peers’ work. You will find those tests especially useful during your defense. Indeed, during defense, you are free to use your tests and/or the tests of the peer you are evaluating.
  • Submit your work to your assigned git repository. Only the work in the git repository will be graded. If Deepthought is assigned to grade your work, it will be done after your peer-evaluations. If an error happens in any section of your work during Deepthought’s grading, the evaluation will stop.

Mandatory Part

Program name: libft.a

Turn in files: Makefile, libft.h, ft_*.c

Makefile: NAME, all, clean, fclean, re

External functions: Detailed below

Libft authorized: n/a

Description: Write your own library: a collection of functions that will be a useful tool for your cursus.

Technical Considerations

  • Declaring global variables is forbidden.
  • If you need helper functions to split a more complex function, define them as static functions. This way, their scope will be limited to the appropriate file.
  • Place all your files at the root of your repository.
  • Turning in unused files is forbidden.
  • Every .c file must compile with the flags -Wall -Wextra -Werror.
  • You must use the command ar to create your library. Using the libtool command is forbidden.
  • Your libft.a has to be created at the root of your repository.

Part 1 - Libc functions

To begin, you must redo a set of functions from the libc. Your functions will have the same prototypes and implement the same behaviors as the originals. They must comply with the way they are defined in their man. The only difference will be their names. They will begin with the ’ft_’ prefix. For instance, strlen becomes ft_strlen.

Some of the functions’ prototypes you have to redo use the ’restrict’ qualifier. This keyword is part of the c99 standard. It is therefore forbidden to include it in your own prototypes and to compile your code with the -std=c99 flag.

You must write your own function implementing the following original ones. They do not require any external functions:

  • isalpha
  • isdigit
  • isalnum
  • isascii
  • isprint
  • strlen
  • memset
  • bzero
  • memcpy
  • memmove
  • strlcpy
  • strlcat
  • toupper
  • tolower
  • strchr
  • strrchr
  • strncmp
  • memchr
  • memcmp
  • strnstr
  • atoi

In order to implement the two following functions, you will use malloc():

  • calloc
  • strdup

Bonus Part

If you completed the mandatory part, do not hesitate to go further by doing this extra one. It will bring bonus points if passed successfully.

Functions to manipulate memory and strings are very useful. But you will soon discover that manipulating lists is even more useful.

You have to use the following structure to represent a node of your list. Add its declaration to your libft.h file:

typedef struct s_list
{
    void *content;
    struct s_list *next;
} t_list;

The members of the t_list struct are:

  • content: The data contained in the node. void * allows to store any kind of data.
  • next: The address of the next node, or NULL if the next node is the last one.

In your Makefile, add a make bonus rule to add the bonus functions to your libft.a.

The bonus part will only be assessed if the mandatory part is PERFECT. Perfect means the mandatory part has been integrally done and works without malfunctioning. If you have not passed ALL the mandatory requirements, your bonus part will not be evaluated at all.

Submission and Peer-Evaluation

Turn in your assignment in your git repository as usual. Only the work inside your repository will be evaluated during the defense. Don’t hesitate to double check the names of your files to ensure they are correct. Place all your files at the root of your repository.

Resources and Testing

Here are some useful resources and testing tools to help you with your libft project:


Thank you for checking out the libft project! Happy coding!

42porto_libft's People

Contributors

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