Code Monkey home page Code Monkey logo

42_ft_printf's Introduction

ft_printf

Overview

ft_printf is a project at 42 that aims to mimic the behavior of the original printf function. The project is written in C and is a part of the curriculum at 42. it's a great project to learn about variadic functions and how to parse and format strings.

Key Features

The project contains 2 parts: Mandatory and Bonus. you need also create a Makefile to compile the project.

  • Mandatory part is about implementing wihtout buufering the basic functionality of the printf function like conversion specifiers: cspdiuxX% and return the number of printed characters.
  • Bonus part is about implementing the following conversion flags and manage with them all: #0-+. yes the last character is a space.

Getting Started

to compile the project you need to clone the repository first, to do that run the following command:

git clone https://github.com/whoismtrx/42_ft_printf.git ft_printf
cd ft_printf
make

Usage

to use the ft_printf function you need to include the header file in your project:

// example.c
#include "ft_printf.h"
cc example.c libftprintf.a -o example

Implementation

ft_printf function supports the following conversion specifiers, width and flags:

  • specifiers:

    • % : print a % character.
    • c : print a character.
    • s : print a string.
    • p : print a pointer address.
    • d : print a decimal number.
    • i : print an integer.
    • u : print an unsigned integer.
    • x : print a hexadecimal number in lowercase.
    • X : print a hexadecimal number in uppercase.
  • width:

    • number : set the width to the number.
  • flags:

    • # : print the number in an alternative format.
    • 0 : print the number with leading zeros.
    • - : left-justify the number.
    • + : print the number with a sign.
    • . : print the number with a precision.
    • space : print the number with a space if no sign is printed.

Resources

you can find some resources about the project in the following links:

  • variadic functions: this is a great video about variadic functions and how to use them in C.
  • printf: this is a great article about printf, also you can read this pdf Secrets of printf to understand how printf works.

42_ft_printf's People

Contributors

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