-
Notifications
You must be signed in to change notification settings - Fork 0
/
man_3_printf
executable file
·69 lines (65 loc) · 2.54 KB
/
man_3_printf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
.TH man 3 "14 October, 2022" "0.10" "_printf man page"
.SH NAME
.B _printf
- Formatted output conversion.
.SH SYNOPSIS
.B #include "main.h"
.B int _printf(const char *
.I format
.B , ...)
.SH DESCRIPTION
.B _printf()
Prints to standard output under the control of a
.I format
string that specifies how subsequent arguments are converted for output.
.SH Return value
On successful return, these functions return 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.
.SH Format of the format string
The format string is composed of 0 or more directives (ordinary characters that are not %), which are copied to the output stream. The format string is also composed of conversion specifications, each of which result in fetching zero or more subsequent arguments. Each conversion specification is introduced by the character % and ends with the conversion specifier.
The argument must correspond properly with the conversion specifier. By default, the arguments are used in the order given.
.SH The conversion specifier
A character that specifies the type of conversion to be applied. The conversion specifiers and their meanings are:
.TP
.BR c
The int argument is converted to an unsigned char, then the resulting character is written
.TP
.B 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 a terminating null byte, but do ot include the terminating null byte.
.TP
.B S
Prints a string. Non printable characters are printed as "\x" followed by their ASCII values in two digit hexadecimal
.TP
.B d, i
The int argument is converted to signed decimal notation.
.TP
.B x, X
The unsigned int argument is converted to unsigned lowercase hexadecimal notation(x), or unsigned uppercase hexadecimal notation(X).
.TP
.B u
The unsigned int argument is converted to unsigned decimal notation
.TP
.B o, b
The unsigned int argument is converted to unsigned octal notation(o) or binary notation(b).
.TP
.B p
Address is printed in hexadecimal.
.TP
.B r
Prints a string in reverse.
.TP
.B R
Prints a string converted to rot13
.TP
.B %
A '%' is written but no argument is converted. The complete version specification is '%%'
.SH EXAMPLE
To print the day of the year, where weekday and month are pointers to strings and day and year are integers:
#include "main.h"
_printf("%s, %s %d, %d\\n", weekday, month, day, year);
.SH SEE ALSO
.I printf(3)
.SH BUGS
No known bugs.
.SH AUTHOR
David Oluwafemi, Peter Simiyu