-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathman_3_printf
executable file
·95 lines (80 loc) · 2.91 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
93
94
95
.TH "29 July 2019" "1.0" "_printf man page"
.SH NAME
_printf
.SH SYNOPSIS
To use this function the #include "holberton.h" header is needed.
.SH DESCRIPTION
Prototype: int _printf(const char *format, ...);
The _printf() function produces output according to a format which is described
below. This function write its output to the stdout, the standard output stream.
.SS RETURN
_printf returns num of characteres printed
Validate: null byte used to end strings or negative value for errors
.SS Format string
Ordinary character (not%) and specification to coversions whit %
"%%" formats do not consume an argument, it will just print a single "%"
.SS The conversion specifiers
The character % is followed by the following specifiers:
i,d The int argument to signed decimal
u The unsigned int argument to unsigned decimal
o The unsigned int argument to unsigned octal
X,x Prints hexadecimal value with upper case letters
S prints the string where Non printable characters
p The void * pointer argument is printed in hexadecimal
.SS The flag characters
The character % is followed by zero or more of the following flags:
# The value should be converted to an "alternate form".
' '(a space) A blank should be left before a positive number
(or empty string) produced by a signed conversion.
+ A sign (+ or -) should always be placed before a number produced
by a signed conversion.By default a sign is used only for negative
numbers.A + overrides a space if both are used.
.SH EXAMPLES
#include <limits.h>
#include <stdio.h>
#include "holberton.h"
/**
* main - Entry point
*
* Return: Always 0
*/
int main(void)
{
int len;
int len2;
unsigned int ui;
void *addr;
len = _printf("Let's try to printf a simple sentence.\n");
len2 = printf("Let's try to printf a simple sentence.\n");
ui = (unsigned int)INT_MAX + 1024;
addr = (void *)0x7ffe637541f0;
_printf("Length:[%d, %i]\n", len, len);
printf("Length:[%d, %i]\n", len2, len2);
_printf("Negative:[%d]\n", -762534);
printf("Negative:[%d]\n", -762534);
_printf("Unsigned:[%u]\n", ui);
printf("Unsigned:[%u]\n", ui);
_printf("Unsigned octal:[%o]\n", ui);
printf("Unsigned octal:[%o]\n", ui);
_printf("Unsigned hexadecimal:[%x, %X]\n", ui, ui);
printf("Unsigned hexadecimal:[%x, %X]\n", ui, ui);
_printf("Character:[%c]\n", 'H');
printf("Character:[%c]\n", 'H');
_printf("String:[%s]\n", "I am a string !");
printf("String:[%s]\n", "I am a string !");
_printf("Address:[%p]\n", addr);
printf("Address:[%p]\n", addr);
len = _printf("Percent:[%%]\n");
len2 = printf("Percent:[%%]\n");
_printf("Len:[%d]\n", len);
printf("Len:[%d]\n", len2);
_printf("Unknown:[%r]\n");
printf("Unknown:[%r]\n");
return (0);
}
.SH SEE ALSO
printf(3)
.SH BUGS
No known bugs.
.SH AUTHOR
Luis Diaz, Kelly Villa