GithubHelp home page GithubHelp logo

simon-zerisenay / 42-ft_printf Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 136 KB

42 ft_printf: ft_printf is a project that involves recreating the functionality of the printf function from the standard C library. The project focuses on parsing format specifiers, formatting output, and handling various data types.

Makefile 9.44% C 90.56%
c libft42 printf printf-42 42abudhabi 42school ecole42

42-ft_printf's Introduction

ft_printf - 42 Abu Dhabi

42 Badge

Score

100

Introduction

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

Welcome to the ft_printf project! This project is part of the curriculum at 42 Abu Dhabi and aims to develop your understanding of variadic functions and string formatting in the C programming language. ft_printf is a custom implementation of the printf function, which allows for formatted output to the standard output stream.

Objective

The main objective of this project is to recreate the printf function, providing similar functionality and behavior. By building your own version of printf, you will deepen your understanding of the inner workings of the function and gain hands-on experience in string manipulation, handling format specifiers, and managing variadic arguments.

Features

Format Specifiers

The ft_printf function supports a wide range of format specifiers, allowing you to format and print various types of data. Some of the commonly used format specifiers include:

%c: Character
%s: String
%d or %i: Signed decimal integer
%u: Unsigned decimal integer
%x or %X: Unsigned hexadecimal integer
%f: Floating-point number
%p: Pointer address


These format specifiers enable you to print data in a specific format, making it easier to display and interpret different types of information.

Width and Precision You can specify the width and precision of the output using optional flags in the format specifier. The width determines the minimum number of characters to be printed, while the precision specifies the maximum number of characters to be printed for strings or the number of decimal places for floating-point numbers.

Flags and Modifiers The ft_printf function supports various flags and modifiers to customize the output. Some of the commonly used flags include:

-: Left-justify the output +: Prepend a plus sign to positive numbers 0: Pad the output with zeros #: Add the "0x" or "0X" prefix for hexadecimal values

These flags and modifiers allow you to modify the appearance of the output to meet your specific requirements.

Variadic Argument Handling


One of the key aspects of ft_printf is its ability to handle variadic arguments. By utilizing the stdarg.h header and the va_list type, you can process a variable number of arguments passed to the function. This flexibility enables you to handle different types of data and dynamically generate the output based on the provided format specifiers.

Installation and Usage


To use ft_printf in your project, follow these steps:

Clone the repository:

                       git clone https://github.com/your_username/42-ft_printf.git

Navigate to the project directory:

					cd 42-ft_printf

Compile the ft_printf library:

					 make

Use the ft_printf executable to execute the programme standard output stream:

					./ft_printf

Refer to the project's documentation and code files for more detailed information and examples of how to use the ft_printf function effectively.

How it Works


The ft_printf function follows a systematic process to handle the provided format string and corresponding arguments:

Parse the format string and identify format specifiers, flags, width, precision, and modifiers. Retrieve the arguments based on the format specifiers and perform necessary data conversions. Generate the formatted output according to the specified format and desired appearance. Print the final output to the standard output stream.
By following this process, ft_printf ensures accurate formatting and printing of the provided data, mimicking the behavior

42-ft_printf's People

Contributors

simon-zerisenay avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.