-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathman_3_printf
More file actions
131 lines (131 loc) · 4.57 KB
/
man_3_printf
File metadata and controls
131 lines (131 loc) · 4.57 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
.TH man 3 "July 2019" "1.0" "_printf man page"
.SH NAME
.B _printf - format and print data
.SH SYNOPSIS
printf FORMAT [ARGUMENT]...
.br
printf OPTION
.LP
#include "holberton.h"
.br
#include <stdlib.h>
.br
#include <stdint.h>
.LP
int printf(const char *format, ...);
.br
int _putchar(char c);
.br
int print_octal(unsigned int n);
.br
int print_number(int n);
.br
int print_unsig(unsigned int n);
.br
int _printstring(char *s);
.br
int print_hexaup(unsigned int n);
.br
int print_hexalow(unsigned int n);
.br
int print_hl(uintptr_t n);
.br
int print_bi(unsigned int n);
.br
int print_rev(char *);
.br
int rot13(char *point);
.LP
#include <stdarg.h>
.LP
int _withformat(char c, int count, va_list valist);
.br
int _withformat2(char c, int count, va_list valist);
.br
int _withformat3(char c, int count, va_list valist);
.br
int _withformat4(char c, int count, va_list valist);
.LP
.SH DESCRIPTION
printf ARGUMENT(s) according to FORMAT.
.LP
The functions in our _printf() family produce output according to a format as described below. the funcions _withformat(), _withformat2(), _withformat3() and _withformat4() works to search the different cases of format and find the correct function, they only work together with _printf.
.br
Also functions like print_number(), printf_octa(), print_unsig(), print_hexaup(), print_hexalow(), print_hl() and print_bi() works to convert and print numbers.
.br
and the functions _putchar(), _printstring(), rot13() and print_rev() works with characters.
.LP
.B Return value
.br
Upon successful return, these functions 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.
.LP
.B The conversion specifier
.LP
A character that specifies the type of conversion to be applied.
.br
the conversion specifiers and their meanings are:
.LP
d, i The int argument is converted to signed decimal notation. The preci‐
sion, if any, gives the minimum number of digits that must appear; if
the converted value requires fewer digits, it is padded on the left
with zeros. The default precision is 1. When 0 is printed with an
explicit precision 0, the output is empty.
.LP
s If 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 (but not including) a ter‐
minating null byte ('\0'); if a precision is specified, no more than
the number specified are written. If a precision is given, no null
byte need be present; if the precision is not specified, or is greater
than the size of the array, the array must contain a terminating null
byte.
.LP
c The int argument is converted to an char, and the resulting character is
written.
.LP
o, u, x, X
The unsigned int argument is converted to unsigned octal (o), unsigned
decimal (u), or unsigned hexadecimal (x and X) notation. The letters
abcdef are used for x conversions; the letters ABCDEF are used for X
conversions. The precision, if any, gives the minimum number of dig‐
its that must appear; if the converted value requires fewer digits, it
is padded on the left with zeros. The default precision is 1. When 0
is printed with an explicit precision 0, the output is empty.
.LP
b The unsigned int argument is converted to a binary, and return the leng of number.
.LP
R If the const char * argument is expected to be a pointer to an array of
character type (pointer to a string).
Characters from the array will be convert to rot13 notation.
.LP
r If The const char * argument is expected to be a pointer to an array
of character type (pointer to a string).
The string will be printed in reverse.
.LP
p The void * pointer argument is printed in hexadecimal.
.LP
% A '%' is written. no argument is converted.
.LP
.B FORMAT controls the output as in C printf.
.LP
\\n new line
.LP
%% a sigle %
.LP
.B NOTE: Shell may have its own version of printf, wich would be most extensive and amazing that this version.
.SH EXAMPLE
To print a integer number:
#include "holberton.h"
.LP
_printf("%d", integer);
.LP
integer must be have a integet value.
.SH SEE ALSO
printf(1), printf(3)
.SH BUGS
No known bugs, but this function maybe have bugs using the conversion specifiers o, u, x, X, if you find some bug
let us know :).
.SH AUTHOR
Michael Sosa, Diego Vivas.