{"id":20255918,"url":"https://github.com/publioelio/school-42-printf","last_synced_at":"2025-04-11T00:12:37.785Z","repository":{"id":173666347,"uuid":"550890684","full_name":"PublioElio/School-42-printf","owner":"PublioElio","description":"This repository contains all files for the printf project from School 42 Málaga cursus. The project consist in duplicate the printf function, part of the stdio.h library ","archived":false,"fork":false,"pushed_at":"2022-11-03T18:47:44.000Z","size":1316,"stargazers_count":17,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-11T00:12:29.458Z","etag":null,"topics":["42cursus","42projects","42school","c-language","ecole42","printf","school-42-malaga"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PublioElio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2022-10-13T13:48:14.000Z","updated_at":"2025-03-14T10:29:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"dc492261-34aa-4a49-b8c8-b5f89763a000","html_url":"https://github.com/PublioElio/School-42-printf","commit_stats":null,"previous_names":["publioelio/school-42-printf"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PublioElio%2FSchool-42-printf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PublioElio%2FSchool-42-printf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PublioElio%2FSchool-42-printf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PublioElio%2FSchool-42-printf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PublioElio","download_url":"https://codeload.github.com/PublioElio/School-42-printf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248317729,"owners_count":21083530,"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":["42cursus","42projects","42school","c-language","ecole42","printf","school-42-malaga"],"created_at":"2024-11-14T10:42:03.942Z","updated_at":"2025-04-11T00:12:37.775Z","avatar_url":"https://github.com/PublioElio.png","language":"C","readme":"\u003cdiv id=\"header\" align=\"center\"\u003e\n  \u003cimg src=\"https://media.giphy.com/media/QXJd9XVrgJuDFhhcOX/giphy.gif\" width=\"200\"/\u003e\n\u003c/div\u003e\n\n\u003ch1 align=\"center\"\u003eSchool 42 printf()\u003c/h1\u003e\n\nThis repository contains all files for the __printf__ project from School 42 Málaga cursus. The project consist in duplicate the [`printf()`](https://es.wikipedia.org/wiki/Printf) function, part of the `stdio.h` library.\n\n\u003ch2 align=\"center\"\u003e\n\t\u003ca href=\"#about\"\u003eAbout\u003c/a\u003e\n\t\u003cspan\u003e · \u003c/span\u003e\n\t\u003ca href=\"#index\"\u003eIndex\u003c/a\u003e\n\t\u003cspan\u003e · \u003c/span\u003e\n\t\u003ca href=\"#requirements\"\u003eRequirements\u003c/a\u003e\n\t\u003cspan\u003e · \u003c/span\u003e\n\t\u003ca href=\"#instructions\"\u003eInstructions\u003c/a\u003e\n\t\u003cspan\u003e · \u003c/span\u003e\n\t\u003ca href=\"#testing\"\u003eTesting\u003c/a\u003e\n\u003c/h2\u003e\n\n## About\nThis project consists in duplicate the behavior of the C function `printf()`. It is not necessary to implement the buffer management of the original function. It must handle the following parameters:\n\n- `char` type variables.\n- `string` type variables.\n- `int` type variables.\n- `unsigned int` type variables.\n- hexadecimal `int` type variables (uppercase and lowercase).\n- `pointer` type variables.\n\nYou will find more details in the [subject of the project](https://github.com/PublioElio/School-42-printf/blob/main/printf.es.subject.pdf).\n\n## Index\n- [Structure](#structure)\n- [Formats](#formats)\n\t- [va_list](#va_list)\n\t- [Returning an integer](#returning-an-integer)\n- [Auxiliary functions](#auxiliary-functions)\n\n### Structure\nThe main obstacles during the execution of the project have been: handling a variable number of parameters and the function `ft_printf()` returning an `int`.\n\n#### `va_list`\nTo deal with the variable number of parameters entered, the macros `va_list`, `va_start`, `va_arg` and `va_end` have been used. The `ft_printf()` function calls the `ft_fotmat()` function when it finds the `%` sign among the entered parameters, then it checks the next character in the string to call one of the functions that print the different variable types. To use this macro, the libraryt `\u003cstdarg.h\u003e` is included in the `ft_printf.h`.\n\n#### Returning an integer\nTo handle the integer returned by `ft_printf()`, a pointer is given in the format printing functions. In this way, the function handles the number of characters printed before continuing with the string sent by parameter. Example:\n\n```\nvoid\tft_putchar_pf(char c, size_t *counter)\n{\n\twrite(1, \u0026c, 1);\n\t(*counter)++; // increasing the pointer with each character printed\n}\n```\n### Formats\nThe different types of variables are printed using a function for each of the formats:\n\n* [__`ft_putchar_pf()`__](https://github.com/PublioElio/School-42-printf/blob/main/ft_putchar_pf.c) prints `char` type variables and is called by each of the following functions to print the character strings one by one. Also, it is where the pointer returned by the `ft_printf()` function is incremented.\n* [__`ft_puthex_pf()`__](https://github.com/PublioElio/School-42-printf/blob/main/ft_puthex_pf.c) prints hexadecimal integers,  using a string included in the `ft_printf.h` library. There is one string for uppercase and one for lowercase characters.\n* [__`ft_putnbr_pf()`__](https://github.com/PublioElio/School-42-printf/blob/main/ft_putnbr_pf.c) recursively prints an integer, handling the maximum negative value with a conditional (`if-else`) and casting the integer to characters.\n* [__`ft_putptr_pf()`__](https://github.com/PublioElio/School-42-printf/blob/main/ft_putptr_pf.c) prints a pointer, in hexadecimal format (lowercase), preceded by the string \"0x\".\n* [__`ft_putstr_pf()`__](https://github.com/PublioElio/School-42-printf/blob/main/ft_putstr_pf.c) prints a `char *` type variable, calling `ft_putchar_pf()` in a `while` loop. It the string is `NULL`, it returns `\"(null)\"`.\n* [__`ft_putuint_pf()`__](https://github.com/PublioElio/School-42-printf/blob/main/ft_putuint_pf.c) prints an `unsigned int` type variable.\n\n### Auxiliary functions\n[__`ft_aux_pf.c()`__](https://github.com/PublioElio/School-42-printf/blob/main/ft_aux_pf.c) this file contains all the auxiliary functions, specifically the `ft_atoi_base` function, [made during the August pool](https://github.com/PublioElio/School42-Piscina-agosto-2022). This function will be used mainly to change the base in functions that handle hexadecimal numbers and `unsigned int` type variables.\n\n## Requirements\nThe functions are written in __C language__ and need the `gcc` compiler, with `\u003cstdlib.h\u003e`, `\u003cstdarg.h\u003e` and `\u003cunistd.h\u003e` standard libraries to run.\n\n## Instructions\n\n### 1. Compiling the archives\n\nTo compile the proiect, go to its path and run:\n\nFor __mandatory__ functions:\n```\n$ make\n```\n### 2. Cleaning all binary (.o) and executable files (.a)\n\nTo delete all files generated with make, go to the path and run:\n```\n$ make fclean\n```\n\n### 3. Using it in your code\n\nTo use this project in your code, simply include this header:\n```\n#include \"ft_printf.h\"\n```\n\n## Testing\nThis function have been tested with [Francinette](https://github.com/xicodomingues/francinette).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpublioelio%2Fschool-42-printf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpublioelio%2Fschool-42-printf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpublioelio%2Fschool-42-printf/lists"}