-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathman_3_printf
executable file
·88 lines (88 loc) · 2.75 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
.TH _printf 3 "27 February 2018" "1.0" "custom man page"
.SH NAME
.B _printf
- formatted output conversion
.SH SYNOPSIS
.B #include "main.h"
.s
int _printf(const char *format, ...);
.SH DESCRIPTION
The function printf() writes output to
.I stdout,
the standard output stream. It writes the output under the control of a format string that specifies how subsequent arguments (or arguments accessed via the variable-length argument facilities of stdarg(3)) are converted for output.
.SS Return value
Upon successful return, this function 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.
.SS Format of the format string
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 subsequent arguments. Each conversion specification is introduced by the character %.
.I conversion specifier.
.SS The flag characters
.SS The field width
.SS The precision
.SS The length modifier
.SS The conversion specifier
A character that specifies the type of conversion to be applied. The conversion specifiers and their meanings are:
.sp
b The
.I int
argument is converted to binary as characters, and the result is written.
.sp
c The
.I int
argument is converted to an unsigned char, and the resulting character is written.
.sp
d, i The
.I int
argument is converted to signed decimal notation.
.sp
o The
.I int
argument is converted to octal as characters, and the result is written.
.sp
r The
.I const char *
argument characters are all printed in reverse.
.sp
R The
.I const char *
argument is encrypted shifting each letter 13 letters down the alphabet. rot13
.sp
s
.RS
The
.I 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').
.RE
.sp
% A '%' is written. No argument is converted. The complete conversion specification is '%%'.
.SH CONFORMING TO
The printf() function conforms to C89.
.SH NOTES
This custom _printf function does not yet handle more
.I flags, field width, precision,
or
.I length modifiers.
.SH EXAMPLE
To print strings and characters:
.sp
.RS
#include <(our files)>
.RE
.RS
_printf("Let's print %c %s\\n", 'a', "string");
.RE
.sp
To print decimal numbers and integers:
.sp
.RS
#include <(our files)>
.RE
.RS
_printf("Max int is %d and min int is %i\\n", 2147483647, -2147483648);
.RE
.SH BUGS
Bugs...
.SH SEE ALSO
.I write(2), printf(3)
.SH AUTHOR
theMaskedOtaku