-
Notifications
You must be signed in to change notification settings - Fork 7
/
man_3_printf
89 lines (89 loc) · 2.65 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
.TH _PRINTF 3 "29 Oct 2019" "Version 1.0" "_PRINTF"
.SH NAME
.B _printf
- formatted output conversion
.SH SYNOPSIS
.B #include "holberton.h"
.LP
.BI "int _printf(const char *"format ", ...);
.SH DESCRIPTION
The
.BR _printf "() function produce output according to a"
.IR format " as described below. Also, write output to " stdout ", the standard output stream."
.LP
The
.BR _printf "() function write 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 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"
.B %
and ends with
.I conversion specifier.
.SS Conversion specifiers
A character that specifies the type of conversion to be applied. The conversion specifiers and their meaning are:
.PP
.BR d ", " i
.RS
The
.I int
argument should be signed decimal notation, and the resulting number is written.
.RE
.PP
.B c
.RS
The
.I int
argument is converted to an char, and the resulting character is written.
.RE
.PP
.B s
.RS
The
.B const char
.I *
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
.PP
.B %
.RS
A '%' is written. No argument is converted. The complete conversion specification is '%%'.
.RE
.SH RETURN VALUE
Upon successful return, the
.B _printf
() function return the number of characters printed (excluding the null byte used to end output to strings).
.LP
If an output error is encountered, a negative value is returned.
.SH SEE ALSO
.I _write(3)
.SH BUGS
No known bugs.
.SH EXAMPLES
To print:
.PP
.RS 3
.B #include "holberton.h"
.PP
_printf("Hello Holberton");
.B // the output will be 'Hello Holberton'
.PP
_printf("%c", 'H');
.B // the ouput will be 'H'
.PP
_printf("%s", "Hello Holberton");
.B // the output will be 'Hello Holberton'
.PP
_printf("%!\\n");
.B // the output will be '%!'
.PP
_printf("Complete the sentence: You %s nothing, Jon Snow.\\n", "know");
.B // the output will be 'Complete the sentence: You know nothing, Jon Snow.'
.PP
_printf("% s", "Hello");
.B // the output will be 'Hello'
.PP
_printf("% k");
.B // the output will be '% k'
.RE
.SH AUTHOR
Jorge Salazar and Santiago Arboleda Londoño