Git Product home page Git Product logo

printf's Introduction

Printf Function

The printf function is a C standard library that formats and print data to the standard output. This repository is our own implementation of the printf function. This implementation will help us gain a deeper understanding of the C language in general, and how the printf function works. So, it is a great learning experience, as we solidify the main concepts of the C programming language.

_Printf Function Prototype

The function of our printf function will declare our function's name: our\_printf, the return type: int, and the parameters: one or more arguments can be passed into the function through variable arguments.

int _printf(const char *format, ...);

Handling the variadic arguments

Inside the our printf function, we iterate over the format string and use the appropriate format specifiers (e.g., %d, %s, etc.) to determine the type and number of arguments to expect. You can further extend this implementation to handle different format specifiers and their corresponding arguments.

Usage

To use the _printf function in your programm, include the main.h header of the _printf function in your C program:

#include "main.h"

int main()
{
    _printf("Hello, %s! The answer is %d.\n", "John", 42);
    return 0;
}

The _printf function surported conversion specifiers

  • %c for printing chars
  • %s for printing strings
  • %S for printing strings with Non-printable in hex
  • %d for printing decimals
  • %i for printing integers
  • %u for printing unsigned int
  • %X for printing hex in uppercase
  • %x for printing hex in lowercase
  • %b for printing binary
  • %o for printing octal
  • %r for printing reversed strings
  • %R for printing ROT13'ed strings
  • %p for printing memory addres

printf's People

Contributors

benard-kiplangat avatar okungbowagodspower 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.