GithubHelp home page GithubHelp logo

printf's Introduction

_printf

This project is about creating a simplified version of the printf function in C. The _printf function is a custom implementation of the C programming language's printf function, which is part of the standard library. The function is variadic, meaning it accepts a variable number of arguments.

Authorized functions and macros

The following functions and macros are used in this project:

  • write (man 2 write)
  • malloc (man 3 malloc)
  • free (man 3 free)
  • va_start (man 3 va_start)
  • va_end (man 3 va_end)
  • va_copy (man 3 va_copy)
  • va_arg (man 3 va_arg)

Compilation

The code is compiled this way:

gcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c

Usage

The _printf function can be used similarly to the printf function. It takes a format string and a variable number of arguments, and writes the output to stdout (the standard output stream).

Here is a basic usage example:

#include "main.h"

int main(void)
{
    _printf("Hello, world!\n");
    return (0);
}

Format Specifiers

The _printf function supports the following format specifiers:

  • %c: Character
  • %s: String of characters
  • %d or %i: Signed decimal integer
  • %b: Unsigned binary
  • %u: Unsigned decimal integer
  • %o: Unsigned octal
  • %x: Unsigned hexadecimal integer (lowercase)
  • %X: Unsigned hexadecimal integer (uppercase)
  • %S: Custom conversion specifier, prints the string. Non printable characters (0 < ASCII value < 32 or >= 127) are printed this way: \x, followed by the ASCII code value in hexadecimal (upper case - always 2 characters)
  • %p: Pointer address
  • %r: Custom conversion specifier, prints the reversed string
  • %R: Custom conversion specifier, prints the Rot13'ed string

Authors

This project is a collaboration between : Oumaima NAANAA & Zidane ZAOUI

More Projects

Simple Shell

ALX Time Saver

ALX Planning Tracker

Monty Language Interpreter

printf's People

Contributors

matsadura avatar naanaa59 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.