- Samuel Idorenyin Ekop (slack: Idorenyin Ekop)
- Samuella Manye Aglago (slack: Ami Aglago)
- Description
- Prototype
- Return Value
- Supported Conversion Specifiers
- Instructions
- Example Usage
- Note
- Collaborators
This project aims to create a custom implementation of the printf
function in C. The function will produce output according to a given format string, which can include conversion specifiers for characters, strings, and the percent symbol. The function will write the output to the standard output stream (stdout).
int _printf(const char *format, ...);
The _printf
function will return the number of characters printed (excluding the null byte used to end output to strings).
The custom printf
function will handle the following conversion specifiers:
%c
: Print a single character.%s
: Print a null-terminated string.%%
: Print a percent symbol.
Additionally, the following conversion specifiers for integers will also be handled:
%d
: Print a signed integer.%i
: Print a signed integer.
-
Clone the repository from GitHub: printf.
-
Implement the custom
_printf
function in the provided source files. You are required to handle the specified conversion specifiers:%c
,%s
,%%
,%d
, and%i
. -
Test your implementation with various test cases to ensure correctness and accuracy.
#include "alx.h"
int main(void)
{
int len;
len = _printf("Hello, %s!\n", "world");
_printf("The number of characters printed is: %d\n", len);
_printf("%c\n", 'A');
_printf("%%\n");
return (0);
}
-
The custom
printf
function does not need to handle flag characters, field width, precision, or length modifiers, as specified in the project instructions. -
The buffer handling of the standard C library
printf
function does not need to be reproduced in this custom implementation.