{"id":17948632,"url":"https://github.com/jose-jaen/ft_printf","last_synced_at":"2025-06-21T03:40:54.175Z","repository":{"id":259103333,"uuid":"876312752","full_name":"jose-jaen/ft_printf","owner":"jose-jaen","description":"Custom implentation of printf function in C","archived":false,"fork":false,"pushed_at":"2024-10-21T19:23:00.000Z","size":21,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-09T04:17:05.774Z","etag":null,"topics":["42","42born2code","42madrid","42school","c","printf","printf-42","programming"],"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/jose-jaen.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":"2024-10-21T18:54:57.000Z","updated_at":"2024-10-22T21:35:49.000Z","dependencies_parsed_at":"2024-10-23T03:38:59.542Z","dependency_job_id":null,"html_url":"https://github.com/jose-jaen/ft_printf","commit_stats":null,"previous_names":["jose-jaen/ft_printf"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jose-jaen%2Fft_printf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jose-jaen%2Fft_printf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jose-jaen%2Fft_printf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jose-jaen%2Fft_printf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jose-jaen","download_url":"https://codeload.github.com/jose-jaen/ft_printf/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247026236,"owners_count":20871347,"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","42madrid","42school","c","printf","printf-42","programming"],"created_at":"2024-10-29T09:07:55.682Z","updated_at":"2025-04-03T15:26:29.173Z","avatar_url":"https://github.com/jose-jaen.png","language":"C","readme":"# ft_printf\n\n## Description\n\nThis goal goal of this project is to recreate the behavior of the `printf` function from `stdio` library in `C`.\n\nWe don't actually have to implement everything, since the mandatory part only covers a limited selection of specifiers:\n\n| Specifier | Description                                       |\n|-----------|---------------------------------------------------|\n| `%c`      | Character. Prints a single character.             | \n| `%s`      | String. Prints a sequence of characters (string). | \n| `%p`      | Pointer. Prints a memory address.                 |\n| `%d`      | Signed decimal integer.                          | \n| `%i`      | Signed decimal integer (same as `%d`).            | \n| `%u`      | Unsigned decimal integer.                         | \n| `%x`      | Unsigned hexadecimal integer (lowercase).         | \n| `%X`      | Unsigned hexadecimal integer (uppercase).         | \n| `%%`      | Prints a literal `%` character.                   | \n\n\nThe function prototype is:\n\n```c\nint ft_printf(char const *format, ...)\n```\n\nWait, `int` is the output type? Yep, turns out `printf` outputs the number of characters it prints!\n\n## Tips\n\n### 1. RTFM!\n\nRead the manual for `printf` [here](https://linux.die.net/man/3/printf). \n\nIt should contain all the information you need to know to correctly implement the function.\n\n### 2. Variadic functions\n\n`printf` can take as many arguments as the user wants, that's why we can't simply fix `n` parameters.\n\nUsing ellipsis `...` as the last parameter declares a variadic function.\n\nReading about `stdarg` library will prove useful. You can do it [here](https://en.cppreference.com/w/c/variadic)\n\n| Macro/Type   | Description                                                                                 |\n|--------------|---------------------------------------------------------------------------------------------|\n| `va_start`   | Enables access to variadic function arguments. Defined in header `\u003cstdarg.h\u003e`.               |\n| `va_arg`     | Accesses the next variadic function argument. Defined in header `\u003cstdarg.h\u003e`.                |\n| `va_copy`    | (C99) Makes a copy of the variadic function arguments. Defined in header `\u003cstdarg.h\u003e`.       |\n| `va_end`     | Ends traversal of the variadic function arguments. Defined in header `\u003cstdarg.h\u003e`.           |\n| `va_list`    | Holds the information needed by `va_start`, `va_arg`, `va_end`, and `va_copy` (typedef).     |\n\n\n### 3. Project structure\n\nYou can use as many directories and C files/headers as you want, I structured my project as follows:\n\n```bash\n├── ft_printf.c\n├── ft_printf.h\n├── libft\n│   ├── *.c\n│   └── libft.h\n├── Makefile\n└── utils\n    ├── ft_printf_char.c\n    ├── ft_printf_hex.c\n    ├── ft_printf_int.c\n    ├── ft_printf_pointer.c\n    ├── ft_printf_string.c\n    └── ft_printf_uint.c\n```\n\nWhere `ft_printf.c` contains the general, abstract implementation logic of `printf`. \n`libft` is a directory with useful functions that are also used in `utils`, a directory specifically created for printing each specifier format.\n\n### 4. Test before pushing!\n\nDon't risk losing evaluation points! Some dedicated students have built useful testers that cover most of the edge cases that Moulinette might throw at you. I personally used [francinette](https://github.com/xicodomingues/francinette).\n\nHere’s how to set it up on your machine:\n\n1) Install it with the following command:\n\n```bash\nbash -c \"$(curl -fsSL https://raw.github.com/xicodomingues/francinette/master/bin/install.sh)\"\n```\n\n2) Navigate to the `francinette` directory and install the required Python libraries:\n\n```python\npython3 -m pip install -r requirements.txt\n```\n\n\u003e **_NOTE:_** It’s a good idea to use a virtual environment. \n\u003e You can create one with: `python3 -m venv .venv`. Then, activate it with: `source .venv/bin/activate` before running the command above.\n\n3) Create an alias for running francinette:\n\nAdd the following line to your `.zshrc` file in your `home` directory:\n\n```bash\nalias paco=\"python3 /home/\u003cintra login\u003e/francinette/main.py\"\n```\n\n4) Create a `Makefile` and test your functions!\n\nYou’ll need a `Makefile` to run the testers. Once it's set up, simply execute the following command in your project directory:\n```bash\npaco\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjose-jaen%2Fft_printf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjose-jaen%2Fft_printf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjose-jaen%2Fft_printf/lists"}