{"id":18877281,"url":"https://github.com/pedrozappa/42_ft_printf","last_synced_at":"2026-02-18T20:30:17.643Z","repository":{"id":206448375,"uuid":"706553944","full_name":"PedroZappa/42_ft_printf","owner":"PedroZappa","description":"42 Project : ft_printf","archived":false,"fork":false,"pushed_at":"2024-07-18T09:16:59.000Z","size":1962,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-12-31T02:21:17.492Z","etag":null,"topics":["42","42born2code","42cursus","42school","c","printf"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PedroZappa.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-18T07:17:44.000Z","updated_at":"2024-12-14T17:03:45.000Z","dependencies_parsed_at":"2023-11-09T17:28:35.189Z","dependency_job_id":"2a2a08f2-b866-4b6b-8e6a-395297912436","html_url":"https://github.com/PedroZappa/42_ft_printf","commit_stats":null,"previous_names":["pedrozappa/ft_printf","pedrozappa/42_ft_printf"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PedroZappa%2F42_ft_printf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PedroZappa%2F42_ft_printf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PedroZappa%2F42_ft_printf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PedroZappa%2F42_ft_printf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PedroZappa","download_url":"https://codeload.github.com/PedroZappa/42_ft_printf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239833540,"owners_count":19704628,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["42","42born2code","42cursus","42school","c","printf"],"created_at":"2024-11-08T06:17:59.912Z","updated_at":"2026-02-18T20:30:17.596Z","avatar_url":"https://github.com/PedroZappa.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ca name=\"readme-top\"\u003e\u003c/a\u003e\n\u003cdiv align=\"center\"\u003e\n\n# ft_printf\n\n( a [42 School](https://github.com/42School) Project )\n\n\u003cp\u003e\n    \u003cimg src=\"https://img.shields.io/badge/score-125%20%2F%20100-success?style=for-the-badge\" /\u003e\n    \u003cimg src=\"https://img.shields.io/github/repo-size/PedroZappa/42_ft_printf?style=for-the-badge\u0026logo=github\"\u003e\n    \u003cimg src=\"https://img.shields.io/github/languages/count/PedroZappa/42_ft_printf?style=for-the-badge\u0026logo=\" /\u003e\n    \u003cimg src=\"https://img.shields.io/github/languages/top/PedroZappa/42_ft_printf?style=for-the-badge\" /\u003e\n    \u003cimg src=\"https://img.shields.io/github/last-commit/PedroZappa/42_ft_printf?style=for-the-badge\" /\u003e\n\u003c/p\u003e\n\n___\n\n\u003ch3\u003eTable o'Contents\u003c/h3\u003e\n\n\n\u003c!-- mtoc-start --\u003e\n\n* [About :pushpin:](#about-pushpin)\n* [Usage :checkered_flag:](#usage-checkered_flag)\n* [Implementation :scroll:](#implementation-scroll)\n* [Constrains ](#constrains-)\n* [Mandatory Requirements:exclamation:](#mandatory-requirementsexclamation)\n* [Bonus Requirements :money_mouth_face:](#bonus-requirements-money_mouth_face)\n* [Structure :construction:](#structure-construction)\n  * [Mandatory Files \u0026 Folder Structure](#mandatory-files--folder-structure)\n  * [Mandatory Processing Flow](#mandatory-processing-flow)\n  * [Bonus Structure:exclamation:](#bonus-structureexclamation)\n    * [Bonus Files \u0026 Folder Structure](#bonus-files--folder-structure)\n  * [Bonus Processing Flow](#bonus-processing-flow)\n  * [License :copyright:](#license-copyright)\n\n\u003c!-- mtoc-end --\u003e\n\n\u003cdiv/\u003e\n\n___\n\n\u003cdiv align=\"left\"\u003e\n\n# About :pushpin:\n\n\u003c/div\u003e\n\n\u003cdiv align=center\u003e\n\n\u003e Because `ft_putnbr()` and `ft_putstr()` aren't enough!\n\nThis project is an exploration into how `printf()` works. The objective is to write a library that mimics the behaviour of `printf()`. A re-code challenge with the aim of revealing how `variadic functions` work in C. This project is an exercise on how to build a well-planned, well-structured extensible code base.\n\n[ft_printf (Subject English)](/ft_printf.en.subject.pdf)\n\n___\n\n\u003cdiv align=\"left\"\u003e\n\n# Usage :checkered_flag:\n\n1. Clone the repo:\n```shell\ngit clone git@github.com:PedroZappa/42_ft_printf.git \n```\n\n2. Initialize local submodules configuration:\n```shell\ngit submodule init\n```\n\n3. Update submodules:\n```shell\ngit submodule update --recursive --remote\n```\n\n4. Build the project:\n```shell\nmake bonus\n```\n\n\n\u003c/div\u003e\n\n____\n\n\u003cdiv align=\"left\"\u003e\n\n# Implementation :scroll:\n\nIn this project `printf()` is implemented with the following prototype:\n\n```c\nvoid\tft_printf(const char *format, ...);\n```\n\n## Constrains \n\n- To accomplish this, the implementation is limited to the use of [libft](https://github.com/PedroZappa/libft) (which makes its performance slower than the standard `printf()`) and a restricted set of standard functions.\n\n    \u003e For **memory allocation** and **deallocation**: `malloc()` and `free()`; \n    \u003e\n    \u003e To **write** into the allocated memory: `write()`;\n    \u003e\n    \u003e To support **variadic functionality**: `va_start()`, `va_arg()`, `va_copy()`, `va_end()`;\n\n- `ft_printf()` doesn't handle overflows and unexpected inputs the same way the real `printf()` would.\n\n## Mandatory Requirements:exclamation:\n\n- Do NOT implement the buffer management of the original `printf()`;\n- The function has to handle the following conversions (format specifiers):\n\n    | Format | Meaning |\n    |--------|---------|\n    | `%c` | Prints a single `char`;\n    | `%s` | Prints a string of characters (`char *`);\n    | `%p` | Prints a Pointer Address in hexadecimal (`void *`);\n    | `%d` | Prints a decimal (base 10) number;\n    | `%i` | Prints an integer in base 10;\n    | `%u` | Prints an unsigned decimal (base 10) number;\n    | `%x` | Prints a number in hexadecimal (base 16) lowercase format;\n    | `%X` | Prints a number in hexadecimal (base 16) uppercase format;\n    | `%%` | Prints a `%` character;\n\n- Format specifiers obey the following prototype:\n\n    ```c\n    %[flags][width][.precision]specifier\n    ```\n\n- The function must behave like `printf()`;\n\n- The library has to be built using the command `ar`;\n\n## Bonus Requirements :money_mouth_face:\n\n- Handle any combination of the following **flags** and **minimum field width** under all conversions;\n\n    |    Flag   | Description |\n    |-----------|---------|\n    |      `-`  | Left justify within given **field width** |\n    |      `0`  | Left-pads the number with zeroes (0) where padding is specified |\n    | `.`       | Precision |\n\n    | .precision | Description |\n    |-----------|---------|\n    | `.number` | For integer specifiers (`%d`, `%i`, `%u`, `%x`, `%X`) - specifies the minimum number of digits to be written. If the value to be written is shorter than this number the result is padded with leading zeroes. The value is not truncated even if the result is longer. A precision of 0 mean that no value is written for the value '0'; For `s`, this is the maximum numbers of characters to be printed. By default all characters are printed until the null terminator is found; |\n    | `.` | The precision is not specified in the format string, but as an additional integer value argument preceding the argument that has to be formatted;\n\n    |   Width    | Description |\n    |------------|---------|\n    | `(number)` | Minimum number of characters to be printed. If the value to be printed is shorter than this value, it is padded with blanks. The value is not truncated even if the result is larger |\n\n- Plus the following flags (yes,one of them is a blank):\n\n    | Flag | Description |\n    |------|---------|\n    | `#` | When used with `x` or `X` specifiers the value is prefixed with `0`, `0x` or `0X` respectively for values different than zero |\n    | ` ` | If no sign is going to be written, print a space before the value |\n    | `+` | Forces a plus or minus sign before printing the result |\n\n## Structure :construction:\n\n#### Mandatory Files \u0026 Folder Structure\n\n`ft_printf()`s mandatory code base has the following file structure:\n\n```mermaid\n---\ntitle ft_printf Structure\n---\nclassDiagram\n    class Makefile\n    Makefile \u003c-- File0\n    class File0[\"ft_printf.h\"]\n    class libft[\"libft.h\"]\n    File0 \u003c-- File1\n    File0 \u003c-- File2\n    File0 \u003c-- File3\n    File0 \u003c-- File4\n    File0 \u003c-- File5\n    libft --\u003e File0\n    class File1[\"ft_printf.c\"]\n    File1 : ft_printf()\n    File1 : ft_newformat()\n    File1 : ft_print_specifier()\n    class File2[\"ft_parse.c\"]\n    File2 : ft_parse()\n    File2 : ft_parse_width()\n    File2 : ft_parse_prec()\n    File2 : ft_parse_bonus()\n    class File3[\"ft_print_chars.c\"]\n    File3 : ft_print_char()\n    File3 : ft_print_str()\n    class File4[\"ft_print_nbrs.c\"]\n    File4 : ft_print_diu()\n    File4 : ft_print_nbr()\n    File4 : ft_sign()\n    class File5[\"ft_print_hex.c\"]\n    File5 : ft_print_x()\n    File5 : ft_print_p()\n    File5 : ft_recurhex()\n    File5 : ft_sharp()\n```\n\n### Mandatory Processing Flow\n\nThe subprocesses of `ft_printf` mandatory implementation are called in the following order:\n\n```mermaid\n---\ntitle ft_printf Processing Flow\n---\ngraph LR;\n    ft_printf--\u003eft_parse;\n    ft_parse--\u003eft_newformat;\n    ft_parse--\u003eft_parse_width;\n    ft_parse--\u003eft_parse_prec;\n    ft_parse--\u003eft_parse_bonus;\n    ft_parse--\u003eft_print_specifier;\n    ft_print_specifier--\u003eft_print_char;\n    ft_print_specifier--\u003eft_print_str;\n    ft_print_specifier--\u003eft_print_diu;\n    ft_print_specifier--\u003eft_print_x;\n    ft_print_specifier--\u003eft_print_ptr;\n    ft_print_diu--\u003eft_print_nbr;\n    ft_print_nbr--\u003eft_sign;\n    ft_print_hex--\u003eft_print_recur_hex;\n    ft_print_hex--\u003eft_sharp;\n    ft_print_ptr--\u003eft_print_recur_hex;\n```\n\n___\n\n### Bonus Structure:exclamation:\n\n#### Bonus Files \u0026 Folder Structure\n\n`ft_printf()`s bonus code base has the following file structure:\n\n```mermaid\n---\ntitle ft_printf w/ Bonus Structure\n---\nclassDiagram\n    class Makefile\n    class libft[\"libft.h\"]\n    \n    class ft_printf_h[\"ft_printf_bonus.h\"]\n    class ft_printf[\"ft_printf_bonus.c\"]\n    class ft_flag_utils[\"ft_flag_utils_bonus.c\"]\n    class ft_flags[\"ft_flags_bonus.c\"]\n    class ft_parse[\"ft_parse_bonus.c\"]\n    class ft_print_c[\"ft_print_c_bonus.c\"]\n    class ft_print_di[\"ft_print_di_bonus.c\"]\n    class ft_print_hex[\"ft_print_hex_bonus.c\"]\n    class ft_print_p[\"ft_print_p_bonus.c\"]\n    class ft_print_s[\"ft_print_s_bonus.c\"]\n    class ft_print_u[\"ft_print_u_bonus.c\"]\n   \n    Makefile \u003c-- ft_printf_h\n    libft --\u003e ft_printf_h\n    ft_printf_h --\u003e ft_printf\n    ft_printf_h --\u003e ft_flag_utils\n    ft_printf_h --\u003e ft_flags\n    ft_printf_h --\u003e ft_parse\n    ft_printf_h --\u003e ft_print_c\n    ft_printf_h --\u003e ft_print_di\n    ft_printf_h --\u003e ft_print_hex\n    ft_printf_h --\u003e ft_print_p\n    ft_printf_h --\u003e ft_print_s\n    ft_printf_h --\u003e ft_print_u\n    \n    ft_printf : ft_printf()\n    ft_flag_utils : ft_isflag()\n    ft_flag_utils : ft_isspecif()\n    ft_flag_utils : ft_isflagtype()\n    ft_flag_utils : ft_isflagtype()\n    ft_flag_utils : ft_pad_width()\n    ft_flags : ft_newformat()\n    ft_flags : ft_resetformat()\n    ft_flags : ft_flag_minus()\n    ft_flags : ft_flag_digit()\n    ft_flags : ft_flag_width()\n    ft_flags : ft_flag_prec()\n    ft_parse : ft_parse_bonus()\n    ft_parse : ft_parse_flags()\n    ft_parse : ft_parse_arg()\n    ft_parse : ft_parse_width()\n    ft_parse : ft_parse_prec()\n    ft_print_c : ft_print_c()\n    ft_print_di : ft_print_di()\n    ft_print_di : ft_print_integer()\n    ft_print_di : ft_print_precision()\n    ft_print_di : ft_print_i()\n    ft_print_hex : ft_print_x()\n    ft_print_hex : ft_print_hexa()\n    ft_print_hex : ft_print_puthex()\n    ft_print_hex : ft_print_putx_prefix()\n    ft_print_p : ft_print_p()\n    ft_print_p : ft_print_ptr()\n    ft_print_p : ft_print_address()\n    ft_print_p : ft_ptrlen()\n    ft_print_s : ft_print_s()\n    ft_print_s : ft_putstr()\n    ft_print_s : ft_print_s_precision()\n    ft_print_s : ft_print_str()\n    ft_print_u : ft_print_u()\n    ft_print_u : ft_print_uint()\n    ft_print_u : ft_print_uint()\n    ft_print_u : ft_print_unsigned()\n```\n\n### Bonus Processing Flow\n\nThe subprocesses of `ft_printf` bonus implementation are called in the following order:\n\n```mermaid\n---\ntitle ft_printf Bonus Processing Flow\n---\ngraph LR;\n    ft_printf--\u003eft_newformat;\n    ft_printf--\u003eft_parse_bonus;\n    ft_parse_bonus--\u003eft_parse_flags;\n    ft_parse_bonus--\u003eft_parse_arg;\n    ft_parse_flags--\u003eft_flag_minus;\n    ft_parse_flags--\u003eft_parse_width;\n    ft_parse_flags--\u003eft_parse_prec;\n    ft_parse_flags--\u003eft_isspecif;\n    ft_parse_arg--\u003eft_putchar_fd;\n    ft_parse_arg--\u003eft_print_c;\n    ft_parse_arg--\u003eft_print_s;\n    ft_parse_arg--\u003eft_print_di;\n    ft_parse_arg--\u003eft_print_u;\n    ft_parse_arg--\u003eft_print_x;\n    ft_parse_arg--\u003eft_print_p;\n\n    ft_print_c--\u003eft_putchar_fd;\n    ft_print_c--\u003eft_pad_width;\n    ft_print_s--\u003eft_pad_width;\n    ft_print_s--\u003eft_putstr;\n    ft_putstr--\u003eft_pad_width;\n    ft_putstr--\u003eft_print_s_precision;\n    ft_print_di--\u003eft_pad_width;\n    ft_print_di--\u003eft_print_integer;\n    ft_print_integer--\u003eft_print_sign_precision;\n    ft_print_integer--\u003eft_print_i;\n    ft_print_integer--\u003eft_pad_width;\n    ft_print_i--\u003eft_pad_width;\n    ft_print_i--\u003eft_print_str;\n    ft_print_x --\u003eft_print_hexa;\n    ft_print_x--\u003eft_pad_width;\n    ft_print_hexa--\u003eft_putx_prefix\n    ft_print_hexa--\u003eft_puthex\n    ft_print_hexa--\u003eft_pad_width;\n    ft_puthex--\u003eft_putx_prefix;\n    ft_puthex--\u003eft_pad_width;\n    ft_puthex--\u003eft_print_str;\n    ft_print_p--\u003eft_print_ptr;\n    ft_print_p--\u003eft_pad_width;\n    ft_print_ptr--\u003eft_print_str;\n    ft_print_ptr--\u003eft_print_address;\n    ft_print_ptr--\u003eft_ptrlen;\n    ft_print_address--\u003eft_print_address;\n```\n\u003c/div\u003e\n\n___\n\n### License :copyright:\n\nThis work is published under the terms of \u003ca href=\"https://github.com/PedroZappa/ft_printf/blob/master/LICENSE\"\u003e42 Unlicense\u003c/a\u003e.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eget to top\u003c/a\u003e)\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpedrozappa%2F42_ft_printf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpedrozappa%2F42_ft_printf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpedrozappa%2F42_ft_printf/lists"}