Synopsis • Description • Format • Supported Functionality Work in Progress
- #include <unistd.h>
- #include <stdarg.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <limits.h>
- #include <string.h>
int _printf(const char *format, ...);
We are currently working on adding support for width, precision and length. To keep track of current funcionality pease review the Suported Functionalitysection.
- Carlon Bentin
- Cristhian Apaza
The function _printf produce output according to a format described below, directed into stdout, the standard output stream. The _printf writes the output under the control of a format string that specifies how subsequent arguments are converted for output.
The format string is a character string, beginning and ending in its initial shift state, if any. The format string is composed of zero or more directives: ordinary characters (not %), which are copied unchanged to the output stream; and conversion specifications, each of which results in fetching zero or more subequents arguments. Each conversion specification is introduced by the character %, and ends with a conversion specifier, like this:
_printf("Hello, %s. project took us %+d days, which in hexa is %#x\n", "World", 5, 5);
Flag | Output | Syntaxis | Example |
---|---|---|---|
+ | Adds + in front of output | ("%+d", 250) | "+250" |
space | Adds '_' in front of ouput | ("% d", 250) | " 250" |
# | Alters format to o, x or X. prefixes 0 for non 0 numbers | ("%#x", 250) | "0xfa" |
CASE | Output | Syntaxis | Example |
---|---|---|---|
r | prints string in reverse | ("%r", "ABC") | "CBA" |
R | prints string encoded using ROT13 | ("%R", "ABC") | "NOP" |
Spec | Output | Syntaxis | Example |
---|---|---|---|
c | character | ("%c", 'A') | "A" |
s | String | ("%s", "ABC") | "ABC" |
d | Decimal | ("%d", 250) | "250" |
i | Integer | ("%i", 250) | "250" |
u | Unsigned Int | ("%u", 250) | "250" |
o | Octal | ("%o", 250) | "372" |
x | Hexadecimal (no caps) | ("%x", 250) | "fa" |
X | Hexadecimal (CAPS) | ("%X", 250) | "FA" |
b | Binary | ("%b", 250) | "11111010" |
- Adding to s - Print Non-printable characters as "\x" followed by ASCII code value in Upper Case Hexadecimal
- Adding [p] - Printing memory adress
- Adding length modifiers [l] [h]
- Adding width modifiers
- Adding precision modifiers
- Adding additional flags: [0], [-]