This team project was done by Oluchime Promise and Beatrice Barbara Stanley, both students of ALX Software Engineering School. This is a part of the curriculum of the ALX-Holberton School and is a required project. The project entails the creation of a function called printf and this function replicates and works exactly like the C standard library printf() function
int _printf(const char *format, ...);
-
All files created were created and compiled on Ubuntu 20.04
-
Code was compiled with
gcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c
..*
- The "main.h" file containing the functions using the _printf() funtion are included
- The syntax for calling is
_printf("format string", arguments...);
_whereformat string
can contain conversion specfiers and flags, alongside regular characters.
-
_printf("This number is %d", 40);
prints "This number is 40." -
_printf("My name is %s\n", John);
prints "My name is John, followed by a new line."
These are the completed tasks for this project and the problems the function aims to solve
[0. I'm not going anywhere. You can print that wherever you want to. I'm here and I'm a Spur for life]
- Write a function that produces output according to a format.
- Returns: the number of characters printed (excluding the null byte used to end output to strings)
c
: converts input into a characters
: converts input into a string
1. Education is when you read the fine print. Experience is what you get if you don't ##* Handle the following conversion specifiers
d
: converts input into a base 10 integeri
: converts input into an integer
- Create a man page for the function
- Handle specific custom conversion specifiers
b
: converts unsigned int to binary
- Handle the following conversion specifiers:
u
: converts input to unsigned integero
: converts the input into an octal numberx
: converts input into hexadecimal numberX
: converts the input into a hexadecimal number with capital letters
- Use a local buffer of 1024 chars in order to call
write
as little as possible.
6. How is the world ruled and led to war? Diplomats lie to journalists and believe these lies when they see them in print ##* Handles the following conversion specifier:
p
: int input is converted to a pointer address
s
: prints the string- Non printable characters (0 < ASCII value < 32 or >= 127) are printed this way: \x, followed by the ASCII code value in hexadecimal (upper case - always 2 characters)
8. The big print gives and the small print takes away ##* Handle the following flag characters for non-custom conversion specifiers:
+
: adds a + in front of signed positive numbers and a - in front of signed negative numbers2. space : same as +, but adds a space (is overwritten by +)#
: adds a 0 in front of octal conversions that don't begin with one, and a 0x or 0x for x or X conversions
- Handle the following length modifiers for non-custom conversion specifiers:
- l : converts
d
,i
,u
,o
,x
,X
conversions in short signed or unsigned ints2. h : convertsd
,i
,u
,o
,x
,X
conversions in long signed or unsigned ints
- Handle the field width for non-custom conversion specifiers.
- Handle the precision for non-custom conversion specifiers.
- Handle the
0
flag character for non-custom conversion specifiers.
13. Every time that I wanted to give up, if I saw an interesting textile, print what ever, suddenly I would see a collection
- Handle the
-
flag character for non-custom conversion specifiers.
- Handle the following custom conversion specifier:
r
: prints the reversed string
- Handle the following custom conversion specifier:
- 'R': prints the rot13'ed string
- All the above options work together