Skip to content

vicire1/19_ft_printf

Repository files navigation

Ft_Printf

Ft_printf

Description

The ft_printf project involves recreating the standard printf() function from the C standard library. The goal is to implement a custom ft_printf() function that mimics the behavior of printf(). This project is an excellent opportunity to learn about variadic functions in C, which allow a function to accept an indefinite number of arguments.

Project Objectives

  • Reimplement the core functionality of the printf() function.
  • Handle various conversions such as characters, strings, pointers, integers, unsigned integers, and hexadecimal numbers.
  • Gain experience in working with variadic functions in C.
  • Develop a deeper understanding of formatted output in C.

Content

  • Implement the ft_printf() function with the following prototype:

    int ft_printf(const char *, ...);
  • Your function must handle the following conversions:

    • %c - Print a single character.
    • %s - Print a string.
    • %p - Print a pointer in hexadecimal format.
    • %d and %i - Print a decimal (base 10) integer.
    • %u - Print an unsigned decimal (base 10) integer.
    • %x - Print a number in hexadecimal (base 16) lowercase format.
    • %X - Print a number in hexadecimal (base 16) uppercase format.
    • %% - Print a percent sign.

Compilation

  1. Compile the library:

    make
  2. Clean object files:

    make clean
  3. Remove all generated files, including the library:

    make fclean
  4. Recompile everything from scratch:

    make re

Usage

To use the ft_printf() function in your project, include the necessary header files and compile your program with the libftprintf.a library:

#include "ft_printf.h"

int main(void) {
    // Example usage
    ft_printf("Hello, ft_printf! Number: %d\n", 42);
    return (0);
}

To compile a program using ft_printf:

gcc -Wall -Wextra -Werror -L[path_to_libftprintf.a] -lftprintf your_program.c -o your_program

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published