GithubHelp home page GithubHelp logo

final-b0ss / libft Goto Github PK

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

My implementation of some of the Standard C Library functions including some additional ones.

License: MIT License

Makefile 3.67% C 96.33%

libft's Introduction

Libft

My implementation of some of the Standard C Library functions including some additional ones.

TOC

What is libft?

[Libft][1] is an individual project at [42][2] that requires us to re-create some standard C library functions including some additional ones that can be used later to build a library of useful functions for the rest of the program.

Disclaimer: Reinventing the wheel is bad, 42 makes us do this just so we can have a deeper understanding of data structures and basic algorithms. At 42 we're not allowed to use some standard libraries on our projects, so we have to keep growing this library with our own functions as we go farther in the program.

What's in it?

As you can see from the [Project instructions][1], there are 4 sections:

  1. Libc Functions: Some of the standard C functions
  2. Additional functions: Functions 42 deems will be useful for later projects
  3. Bonus Functions: Functions 42 deems will be useful for linked list manipulation
  4. Personal Functions: Functions I believe will be useful later. [Documented here][3].

Notes:

  • Most of the the files and function names are namespaced with an ft in front. It stands for Fourty Two
  • The project instructions require that we put all the source files in the root directory but for the sake of this Github repo, I separate them into sub folders.

How does it work?

The goal is to create a library called libft.a from the source files so I can later use that library from other projects at 42.

To create that library, after downloading/cloning this project, cd into the project, copy all the files from the sub folders to the root directory and finally, call make:

git clone https://github.com/Maljean/libft.git
cd libft
make copy
make

You should see a libft.a file and some object files (.o).

Now to clean up (removing the .o files and the .c files from the root), call make clean

WARNING: make clean will delete all your files from your root directory. Do not run it if you're using the Makefile file. This is why I added the Makefile-sample file.

How do I use the library?

I added an example file called example.c, it's using the function ft_putstr to print "DON'T PANIC" to the screen.

If you try to compile it with gcc using gcc example.c you will get an undefined symbol error for ft_putstr.

You have to tell the file where your library resides and which library it is using:

gcc example.c -L. -lft

-L takes the path to your library. . in this case
-l takes the name of your library. This is the set of characters that come after lib in your library name.

That's it. Now run it using ./a.out

How do I test it? How do I test my own implementations?

To test the code we're going to be using @alelievr's [Libft Unit Test][4]. There are [some][5] [good][6] [others][7] but I'll only be covering this one.

1. To test the code in this repo

  1. Clone this repo and cd into it, make sure it's called libft:

     git clone https://github.com/Maljean/libft.git
     cd libft/
    
  2. Copy all the source files to the root directory:

     make copy
    
  3. Run Make so you can build the library:

     make
    
  4. Go back to the root directory and download @alelievr's Libft Unit Test:

     cd ..
     git clone https://github.com/alelievr/libft-unit-test
    
  5. Go into the test folder and run the test:

     cd libft-unit-test/
     make f
    

If you did everything correctly you should get a cool list of tests showing you the function names and if they passed or not.

libft's People

Contributors

final-b0ss avatar

Watchers

James Cloos 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.