Code Monkey home page Code Monkey logo

printf's Introduction

Printf

Arik Rosenthal & Lizzie Turner



Synopsis

#include "holberton.h"

_printf FORMAT [ARGUMENT]...


Description

The _printf function produces output in a specific format, based on the given options, and writes to the standard output. To utilize _printf you must create a main.c file and include the header "holberton.h". Then compile with all the following .c files.

Files Function 1 Function 2 Function 3 Function 4 Function 5
_printf.c _printf
_putchar.c _putchar
get_spec_func.c get_spec_func
char_helpers.c print_char print_percent
number_helpers.c print_decimal print_integer
string_helpers.c print_string print_special_string print_rot13 print_reverse print_pointer
translation_helpers.c print_binary print_unsigned print_octal print_lil_hex print_big_hex
math_helpers.c binary_helper octal_helper lil_hex_helper big_hex_helper long_hex_helper
holberton.h All prototypes
man_3_printf Man Page

Return value

Number of characters printed.

Format of the format string

Unformatted unless specified by user.

The conversion specifier

A character that specifies what type of output to return.


The following specifiers must be preceded by a percent '%' sign, otherwise they are treated like normal characters.

c

The int argument is converted into type char and a single character is written.

s

The argument is of type char *. The full string is written, up to a terminating null byte '\0'.

S

The argument is of type char *. The full string is written, up to a terminating null byte '\0', except for non printable characters, which instead are printed as their ascii value, in hex ie. '\x0A', instead of '\n'.

d, i

The int argument is converted to a signed decimal notation.

p

The long int argument containing an address is printed.

b, o, u, x, X

The unsigned int argument is converted to binary (base 2) b, octal (base 8) o, unsigned decimal u, lowercase hexadecimal x, or UPPERCASE hexadecimal X notation.

r

The argument is of type char *. The full string is written in reverse.

R

The argument is of type char *. The full string is converted into ROT13, each letter is rotated 13 positions, numbers are unaffected.


Example

Here is an example of how you could impliment the '%s' format specifier.

int main(void)
{
	_printf("Print %s!", "this");
	return (0);
}

The preceding function would output Print this!


See Also

printf(1)


Bugs

No known bugs. Please contact one of the authors in regard to any unanticipated behavior.


Prototype

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

printf's People

Contributors

lizzieturner avatar adentintime avatar

Watchers

James Cloos avatar

Forkers

adentintime

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.