-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathman_3_printf
executable file
·92 lines (81 loc) · 2.07 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
89
90
91
92
.\"original file zless /usr/share/man/man3/printf.3.gz
.\"
.TH _PRINTF 3 "22 November 2016" "1.0" "holberton man page"
.SH NAME
.B _printf
- formatted output conversion.
.SH SYNOPSIS
.B #include "our file"
.sp
.BI "int _printf(const char *" format", ...);"
.ad
.SH DESCRIPTION
This function writes output to
.I stdout
according to a
.I format
as described below.
.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
.BR % ),
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
.BR % ,
and ends with a
.IR "conversion specifier" .
In between there may be (in this order) zero or more
.IR flags ,
an optional minimum
.IR "field width" ,
an optional
.I precision
and an optional
.IR "length modifier" .
The arguments must correspond properly (after type promotion) with the
conversion specifier.
By default, the arguments are used in the order
given, where each \(aq*\(aq and each conversion specifier asks for the next
argument (and it is an error if insufficiently many arguments are given).
.SS The flag characters
.SS The field width
.SS The precision
.SS The length modifier
.SS The conversion specifier
.SH EXAMPLE
To print
.I Pi
to five decimal places:
.in +4n
.nf
#include <math.h>
#include <stdio.h>
printf("pi = %.5f\en", 4 * atan(1.0));
.fi
.in
.PP
To print a date and time in the form "Sunday, July 3, 10:02",
where
.I weekday
and
.I month
are pointers to strings:
.in +4n
.nf
#include <stdio.h>
printf( "%s, %s %d, %.2d:%.2d\en",
weekday, month, day, hour, min);
.SH SEE ALSO
.I write(2), printf(3)
.SH BUGS
Hm, well bugs.
.SH AUTHOR
Anne Cognet - Jennie Chu