Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/trustcoodes/printf

Team project (printf) ALX
https://github.com/trustcoodes/printf

Last synced: 7 days ago
JSON representation

Team project (printf) ALX

Awesome Lists containing this project

README

        

Software Enginering Printf Team Project

Synopsis
function _printf() writes output to stdout, the standard output stream with the format and options without making use of any of the standard library files
The prototype of this function is: int _printf(const char format), The format string is a character string starting and ending with double quotes

The field width

An optional decimal digit string (with nonzero first digit) specifying a minimum field width. If the converted value has fewer characters than the field width, it will be padded with spaces on the left if the flag - is not present, and on the right if it is present. A character * can be used instead of a decimal string. In this case, an argument passed to the function will be taken as the width value.

printf("%5d", num);
or

printf("%*d", width, num);
The precision

An optional precision, in the form of a period ('.') followed by an optional decimal digit string. A negative precision is taken as if the precision were omitted. This gives the minimum number of digits to appear for d, i, o, u, x, and X conversions, or the maximum number of characters to be printed from a string for s and S conversions. A character * can be used instead of a decimal string. In this case, an argument passed to the function will be taken as the precision value.

printf("%.3d", num);
or

printf("%.*d", precision, num);