Repository navigation
Expand file tree
/
Copy pathman_3_printf
More file actions
executable file
·89 lines (64 loc) · 2.42 KB
/
Copy pathman_3_printf
File metadata and controls
executable file
·89 lines (64 loc) · 2.42 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
.TH _printf 3 "November 26, 2023" "Version 1.0" "User Commands"
.SH NAME
\fB_printf\fR \- mimic the standard printf function and writes formatted date to the standard output.
.SH SYNOPSIS
.P
\fBint _printf(const char *format, ...);\fR
.P
\fB#include "main.h"\fR
.SH DESCRIPTION
The \fB_printf\fR function mimics the behavior of the standard \fBprintf\fR function and is designed to print formatted output to the standard output stream.
The function scans the string and writes each character to the standard output. When faced with a conversion specifier, the function will call other functions via a va_list, which will convert and write the following characters according to the functions invoked.
.SH CONVERSION SPECIFIERS
.TP 10
\fB%c:\fR
Prints a single character.
.TP 10
\fB%s:\fR
Prints a null-terminated string of characters.
.TP 10
\fB%%:\fR
Prints a single percent sign.
.TP 10
\fB%d:\fR
Prints a decimal number.
.TP 10
\fB%i:\fR
Prints an integer number.
.PP
\fBFlags, Field Width, Precision, Length Modifier:\fR
This simplified version of \fB_printf\fR does not support flags, field width, precision, or length modifiers.
.SH RETURN VALUE
The function returns the number of characters printed (excluding the null byte used to end the output to strings).
If format is NULL or ends with a %, the function returns -1.
.SH EXAMPLES
The following examples illustrates the use of the _printf function:
\fBlen = _printf("Printf is so much fun!\\n");\fR
\fBOutput : "Printf is so much fun!"\fR
\fB_printf("Length:[%d, %i]\\n", len, len);\fR
\fBOutput: "Length:[24, 24]".\fR
\fB_printf("Negative:[%d]\\n", -823405);\fR
\fBOutput: "Negative:[-823405]".\fR
\fB_printf("Character:[%c]\\n", 'A');\fR
\fB"Output: "Character:[A]".\fR
\fB_printf("String:[%s]\\n", "Learning for a lifetime");\fR
\fBOutput: "Learning for a lifetime".\fR
\fBlen = _printf("Percent:[%%]\\n");\fR
\fBOutput: "Percent:[%]".\fR
\fB_printf("Len:[%d]\\n", len);\fR
\fB"Output: "Len:[24]".\fR
\fB_printf("Unknown:[%r]\\n");\fR
\fBOutput: "Unknown:[%r]".\fR
\fB_printf("Len:[%d]\\n", INT_MIN);\fR
\fBOutput: "Len:[-2147483648]".\fR
.SH AUTHORS
.P
Written by \fBJulie Dedieu\fP and \fBSaadi Khemchane\fP.
.SH COPYRIGHT
.P
Copyright (C) 2023, Julie Dedieu.
This is a free software: feel free to change and redistribute it.
NO WARRANTY, to the extent permitted by law.
.SH DATE
November 26, 2023
SH COPYRIGHT