Giter Site home page Giter Site logo

allelomorph / printf Goto Github PK

View Code? Open in Web Editor NEW

This project forked from andrewc7/printf

0.0 0.0 0.0 15 KB

A simple clone of the glibc `printf`. See project (228) 0x11. C - printf from repository `holbertonschool-low_level_programming`.

C 100.00%

printf's Introduction

Notes


0x11. C - printf

Description

  • _printf() produces output according to a format and writes output to stdout, the standard output stream.
  • Upon successful return, _printf() returns the number of characters printed (excluding the null byte used to end output to strings).
    • If an output error is encountered, a negative value is returned.
  • The format string is a character string and is composed of zero or more directives:
    • ordinary characters (not %), which are copied unchanged to the output stream
    • conversion specifications, each of which results in fetching zero or more subsequent arguments. Each conversion specification is introduced by the character %

Flag Characters / Conversion Specifiers

The character % is followed by zero or more of the following flags:

b

  • The unsigned int argument is written in binary.

c

  • The int argument is converted to an unsigned char, and the resulting character is written.

d, i

  • The int argument is converted to signed decimal notation. The default precision is 1.

o

  • The unsigned int argument is written in octal format.

%

  • The percent character is escaped by itself, as with %.

p

  • The long unsigned int argument is converted to hex to be written as a pointer.

R

  • The const char * argument is written in rot13 encoding.

r

  • The const char * argument is written backwards.

s

*The const char * argument is expected to be a pointer to an array of character type (pointer to a string). Characters from the array are written up to (but not including) a terminating null byte ('\0')

u

  • The unsigned int argument is written in base 10 format.

x

  • The unsigned int argument is written in lowercase hex format.

X

  • The unsigned int argument is written in uppercase hex format.

Example

'_printf("String:[%s]\n", "I am a string !");'

Result:

String: [I am a string!]

'_printf("Number:[%d]\n", "1234567");'

Result:

Number:[1234567]


Files:

  • This file contains the meat of our printf() function. We initialize our data type struct, check to edge cases, and loop trough the format string returning the corresponding result.
  • This file contains our helper functions basic printf() functionality. Helpers include: _printchar, _printstr, _printnum, and _printp
  • This file contains all our function prototypes, a declaration of our data type struct, and some standard libraries

Authors

printf's People

Contributors

allelomorph avatar andrewc7 avatar sammessenger avatar

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.