Skip to content

BD20171998/printf

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

0x11. C - printf

Description

This team project is part of the first year curriculum of Holberton School. _printf replicates the C standard library printf() function.

What you should learn from this project:

  • How to use git in a team setting
  • Applying variadic functions to a big project
  • The complexities of printf
  • Managing a lot of files and finding a good workflow

Prototype

int _printf(const char *format, ...);

Usage

  • Prints a string to the standard output, according to a given format
  • All files were created and compiled on Ubuntu 14.04.4 LTS using GCC 4.8.4 with the command gcc -Wall -Werror -Wextra -pedantic *.c
  • All files were linted for syntax and style with Betty
  • Returns the number of characters in the output string on success, -1 otherwise
  • Call it this way: _printf("format string", arguments...) where format string can contain conversion specifiers and flags, along with regular characters

Examples

  • _printf("Hello, Holberton\n") prints "Hello, Holberton", followed by a new line
  • _printf("%s", "Hello") prints "Hello"
  • _printf("This is a number: %d", 98) prints "This is a number: 98"

Tasks

These are all the tasks of this project, the ones that are completed link to the corresponding files.

  • Write a function that produces output according to format.
    • Prototype: int _printf(const char *format, ...);
    • Returns: the number of characters printed (excluding the null byte used to end output to strings)
    • write output to stdout, the standard output stream
    • format is a character string. The format string is composed of zero or more directives. See man 3 printf for more detail. You need to handle the following conversion specifiers:
      • c : converts input into a character
      • s : converts input into a string
  • Handle the following conversion specifiers:
    • d : converts input into a base 10 integer
    • i : converts input into an integer
  • Create a man page for your function
  • Handle the following conversion specifiers:
    • b : the unsigned int argument is converted to binary
alex@ubuntu:~/c/printf$ cat main.c
#include "holberton.h"

/**
 * main - Entry point
 *
 * Return: Always 0
 */
int main(void)
{
    _printf("%b\n", 98);
    return (0);
}
alex@ubuntu:~/c/printf$ gcc -Wall -Wextra -Werror -pedantic main.c
alex@ubuntu:~/c/printf$ ./a.out
1100010
  • Handle the following custom conversion specifier:
    • r : prints the reversed string
  • Handle the following custom conversion specifier:
    • R : prints the rot13'ed string

Authors

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 100.0%