Code Monkey home page Code Monkey logo

printf's Introduction

MIT License

Recreation printf Function

Description

The _printf() function takes one argument:

A string with / without specifiers to print and gives the output formatted.

The string is printed character by character and when founds a '%' with a letter calls one of that parameters and print them instead the specifiers.

Table of Content

Usage

Like the according main.h library version:

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

Format Specifiers

Format generators are a format with which we tell the function to take the arguments ​​according to the indicated type.

A format specifier follows this prototype: %type The following format specifiers are supported:

Type Output
c Print a character passed as parameter
s Prints a string
% Print a percentage symbol
d Prints a signed decimal number
i Prints a signed number (int)
b Converts the unsigned integer to binary and prints it
r Print the inverted string
R Use ROT13 to converts the letters with the thirteenth letter forward of the alphabet.

Future Features

Type Output
u Prints an unsigned decimal number
o Prints the octal unsigned integer conversion
x Unsigned hex conversion to lowercase
X Unsigned hex conversion to uppercase
p Print a memory address(pointer)

Bugs

  • %b : The specifier %b doesn't work all correctly

Examples

#include "main.h"

int main (void)
{
    _printf ("I am a character %s", 'F');

    return (0);
}

Output : I am a character F

#include "main.h"

int main (void)
{

    _printf ("%s", "STRING");

    return (0);
}

Output : STRING

#include "main.h"

int main (void)
{

    _printf ("I am percentage %%");

    return (0);
}

Output : I am a percentage %

#include "main.h"

int main (void)
{

    _printf ("I am an integer %i", 10);

    return (0);
}

Output : I am an integer 10

#include "main.h"

int main (void)
{

    _printf ("I am a binary %b", 54);

    return (0);
}

Output : I am a binary 110110

Authors

License

MIT

printf's People

Contributors

luismch158158 avatar wardencode avatar

Watchers

 avatar

Forkers

jpticse

printf's Issues

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.