Code Monkey home page Code Monkey logo

ft_printf's Introduction

ft_printf

Final Score 102/100

Challenge

Recode libc's printf function.

At 42, Students must write all their own functions from scratch.
Normal library functions such as realloc, strjoin, strdup, etc., are strictly forbidden.

ft_printf must achieve the following requirements:

  • Manage the following conversions: s, S, p, d, D, i, o, O, u, U, x, X, c & C
  • Manage %%
  • Manage the flags #, 0, -, + & space
  • Manage the minimum field-width
  • Manage the precision
  • Manage the flags hh, h, l, ll, j, & z.

ft_printf must conform to the 42 Norm. It must not have any leaks. Errors must be handled carefully.
In no way can it quit in an unexpected manner (segmentation fault, bus error, double free, etc).

ft_printf must be formatted and behave in the same way as libc's printf:

  ft_printf("%d is the answer to %s, %s, and %s.", 42, "life", "the universe", "everything");
  printf("%d is the answer to %s, %s, and %s.", 42, "life", "the universe", "everything");

Should output:

  42 is the answer to life, the universe, and everything.
  42 is the answer to life, the universe, and everything.

Usage

Run make. This will compile libftprintf.a. To use, include ft_printf.h and use just like printf:

#include <ft_printf.h>

int     main(void)
{
  ft_printf("%s\n", "Hello World");
  return(0);
}

Then compile with a program:

$> gcc -Wall -Werror -Wextra main.c libftprintf.a -I includes 

ft_printf's People

Stargazers

 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.