Git Product home page Git Product logo

printf's Introduction

Printf Function Implementation

This repository contains an implementation of the printf function in C, which allows you to format and print various types of data to the standard output. The printf function is widely used in C programming for formatted printing.

Table of Contents

Description

The printf function in this implementation provides similar functionality to the standard printf in C. It supports the following format specifiers:

  • %c: Print a character.
  • %s: Print a string.
  • %d or %i: Print an integer.
  • %b: Print an unsigned integer in binary format.
  • %%: Print a percent sign.

Usage

To use the printf function in your C program, include the main.h header file and call the _printf function, providing the format string and any necessary arguments. Here's an example:

#include "main.h"

int main(void) {
    int char_count;

    char_count = _printf("Hello, %s! You have %d apples.\n", "John", 42);
    return (0);
}

Functionality

  • print_char: Prints a character.
  • print_string: Prints a string.
  • print_int: Prints an integer.
  • print_binary: Prints an unsigned integer in binary format.
  • handle_format_specifier: Handles format specifiers and delegates printing to the appropriate functions.
  • _printf: The main printf function that takes the format string and variable arguments.

How to Compile

Compile your program with the provided main.c file and your source files. For example:

gcc -Wall -Werror -Wextra -pedantic main.c your_file.c -o your_program

Examples

Here are some example usages of the printf function:

_printf("Hello, %s!\n", "World");
_printf("The answer is %d.\n", 42);
_printf("Binary representation of %d is %b.\n", 10, 10);
_printf("A percent sign: %%\n");

printf's People

Contributors

devbasem avatar mrwolf0 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.