The _printf() function produces output according to a format which is described below. This function write its output to the the standard output stream, stdout. It returns the count of printed characters when the function is successful and 1 when the function fails.
-
%c: Prints a single character.
-
%d: Prints integers.
-
%b: Prints the binary representation of an unsigned decimal.
-
%x: Prints the hexadecial representation of an unsigned decimal in lowercase letters
-
%X:Prints the hexadecial representation of an unsigned decimal in uppercase letters
-
%R: Prints the Rot13 interpretation of a string
-
%s: Prints a string of characters.
-
All the files are to be compiled on Ubuntu 14.04 LTS
-
Include the "main.h" header file on the functions using the _printf()
-
Compile your code with $ gcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c
#include "main.h"
#include <stdio.h>
/**
* main - Entry point
*
* Return: Always 0
*/
int main(void)
{
int a;
int b;
char *str;
str = "school";
a = _printf("%r\n", "Alx"); /*expected: xlA*/
printf("--->%d\n", a); /*expected: 10*/
b = _printf("%r\n", str); /*expected: loohcs*/
printf("%d\n", b); /*expected: 7*/
b = _printf("%r\n", str); /*expected: loohcs*/
printf("%d\n", b); /*expected: 7*/
return (0);
}
Custom Printf Function That Performs Formatted Output Conversion And Print Data.
Header File Were All Prototypes Are Saved.
Pointer To A Function That Selects The Correct Function To Perform The Operation.
Function That Prints The Buffer.
Function That Concatenates The Buffer Characters.
Function That Writes The Character C To Stdout.
/* Identifier : %c */
Function That Writes The String To Stdout.
/* Identifier : %s */
Function That Prints An Integer.
/* Identifier : %i or %d */
Function That Prints Decimal In Binary.
/* Identifier : %b */
Function That Prints Decimal In Octal.
/* Identifier : %o */
Function That Prints Decimal In Hexadecimal.
/* Identifier : %x */
Function That Prints Decimal In Uppercase Hexadecimal.
/* Identifier : %X */
Function That Prints A String And Values Of Non-Printed Chars.
/* Identifier : %S */
Function That Prints An Unsigned Integer.
/* Identifier : %u */
Function That Writes The String To Stdout In Reverse.
/* Identifier : %r */
Function That Writes The String To Stdout In Rot13.
/* Identifier : %R */
Function That Prints The Address Of An Input Variable.
/* Identifier : %p */
Function That Prints Long Decimal Number In Octal.
/* Identifier : %lo */
Function That Prints Long Decimal Number In Hexadecimal.
/* Identifier : %lx */
Function That Prints A Long Integer.
/* Identifier : %li */
Function That Prints A Long Decimal In Uppercase Hexadecimal.
/* Identifier : %lX */
Function That Prints A Long Unsigned Integer.
/* Identifier : %lu */
Function That Prints Short Decimal Number In Octal.
/* Identifier : %ho */
Function That Prints Short Decimal Number In Hexadecimal.
/* Identifier : %hx */
Function That Prints A Short Integer.
Function That Prints A Short Decimal In Uppercase Hexadecimal.
/* Identifier : %hX */
Function That Prints A Short Unsigned Integer.
/* Identifier : %hu */
Function That Print A Number In Hexadecimal Begining With 0 And x.
/* Identifier : %#x */
Function That Prints A Number In Octal Begining With 0 And o.
/* Identifier : %#o */
Function That Prints A Number In Uppercase Hexadecimal.
/* Identifier : %#X */
Function That Prints An Integer With Plus Symbol.
/* Identifier : %+i */
Function That Prints An Integer Begining With 0 And u.
/* Identifier : % i */
Function That Returns The Amount Of Identifiers.