Skip to content

Reimplementação do printf em C, usando apenas funções permitidas como write, malloc e va_arg. Suporte completo a múltiplos formatos e retorno do número de caracteres impressos.

Notifications You must be signed in to change notification settings

handyman0/ft_printf

Repository files navigation

ft_printf

Because putnbr and putstr aren't enough

GitHub code size in bytes Number of lines of code Code language count GitHub top language GitHub last commit


💡 About the project

This project is pretty straight forward. You will recode printf. You will mainly learn how to use variadic arguments.

This project consists of coding a library that contains a simplified version of the printf function, implementing basic format specifiers and learning how to handle variadic arguments in C.

Implemented specifiers:

  • %c - Character
  • %s - String
  • %p - Pointer address
  • %d - Decimal integer
  • %i - Integer
  • %u - Unsigned decimal
  • %x - Hexadecimal (lowercase)
  • %X - Hexadecimal (uppercase)
  • %% - Percent sign

🛠️ Usage

Requirements

The function is written in C language and thus needs the gcc compiler and some standard C libraries to run.

Instructions

1. Compiling the library

To compile, go to the library path and run:

$ make

2. Using it in your code

To use the library functions in your code, simply include its header:

#include "ft_printf.h"

Example usage:

#include "ft_printf.h"

int main(void)
{
    ft_printf("Hello %s!\n", "world");
    ft_printf("Number: %d\n", 42);
    ft_printf("Hex: %x\n", 255);
    return (0);
}

📋 Testing

You can use this third party tester to fully test the project:

Project Structure

About

Reimplementação do printf em C, usando apenas funções permitidas como write, malloc e va_arg. Suporte completo a múltiplos formatos e retorno do número de caracteres impressos.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published