0x11. C - printf

Description

Write a printf function.

Requirements

  • Allowed editors: vi, vim, emacs
  • All your files will be compiled on Ubuntu 14.04 LTS
  • Your programs and functions will be compiled with gcc 4.8.4 using the flags -Wall -Werror -Wextra and -pedantic
  • All your files should end with a new line
  • A README.md file, at the root of the folder of the project is mandatory
  • Your code should use the Betty style. It will be checked using betty-style.pl and betty-doc.pl
  • Not allowed to use global variables
  • No more than 5 functions per file
  • The prototypes of all functions should be included in your header file called holberton.h
  • All header files should be include guarded

Authorized functions and macros

  • 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

Our code will be compiled using: $ gcc -Wall -Werror -Wextra -pedantic *.c

  • a function that produces output according to a format and handles the %c conversion specifier.
  • a function that produces output according to a format and handles the %s con version specifier.
  • a function that produces output according to a format and handles the %% con version specifier.
  • Handle the %d conversion specifier.
  • Handle the %i conversion specifier.
  • Create a man page for your function.
  • Handle the following custom conversion specifiers:
  • b: the unsigned int argument is converted to binary
  • a function that produces output according to a format and handles the %u con version specifier.
  • a function that produces output according to a format and handles the %o con version specifier.
  • a function that produces output according to a format and handles the %x con version specifier.
  • a function that produces output according to a format and handles the %X con version specifier.
  • Use a local buffer of 1024 chars in order to call write as little as possible.
  • Handle the following custom conversion specifier:
  • S : 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)
  • Handle the following conversion specifier: p.
  • Handle the following custom conversion specifier:
  • r : prints the reversed string
  • Handle the following custom conversion specifier:
  • R: prints the rot13'ed string

Author