Giter VIP home page Giter VIP logo

ft_printf's Introduction

ft_printf

Because ft_putnbr() and `ft_putstr() aren’t enough.

A custom implementation of the C library function printf() in C.

Grade: 100/100

Features

This implementation supports the following conversion specifications:

  • %c - Single character
  • %s - String of characters
  • %p - Pointer address
  • %d and %i - Signed decimal integer
  • %u - Unsigned decimal integer
  • %x and %X - Unsigned hexadecimal integer (lowercase and uppercase respectively)
  • %% - Literal % character

Usage

This implementation can be used in the same way as printf().

#include "ft_printf.h"

int main(void) {
    ft_printf("This is a string: %s\n", "Hello, World!");
    ft_printf("This is a number: %d\n", 42);
    return 0;
}

Implementation

The ft_printf() function takes a string as its first argument and additional arguments as required by the conversion specifications in the string.

The function uses the va_start(), va_arg() and va_end() macros to handle the variable argument list. The ft_parseargs() function takes a character representing the conversion specification and the va_list as arguments, and returns the number of characters written to standard output.

The supported conversion specifications are processed through functions such as ft_putchar(), ft_putstr() and ft_putptr() that write the output to standard output.

ft_printf's People

Contributors

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