Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

152 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Holbertonschool-printf

Description

This project aims to recreate the printf function in C. It will handle some basic cases.

#Content

Overview

The function _printf will replicate and handle some of the basic case specifiers from the C printf function and some advanced like hexa decimal, octal, and address conversions.

Features

Basic Format Specifiers: Currently supports %s (strings), %c (characters), and %d %i (integers).

More Format Specifiers: Supports %x %X (hexadecimal),%u (unsigned integers), %o (octal).

Use

Include all the files present in the repository.

my_printf.c --- Contains _printf function.

main.h --- All necessary headers and prototypes.

num_functions.c --- Has all functions that handle number cases.

char_funtcions.c --- Has all functions that handle character cases.

Once you have all files remember to include main.h in your .c file :

#include "main.h"

To use the function simply call it by giving a format string with case specifiers and can be followed by arguments like this :

int total_len = _printf("Hello %s I am %d years old \n", "there", 1000);
_printf("Total characters printed: %d\n", total_len);

Examples

Example of using the _printf function:

#include "main.h"

int main() {

  char str = "there"
  _printf("Hello %s", str);

  return (0);
}

output:

Hello there

Authors

Resources

About

Recreating printf function

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages