Giter Site home page Giter Site logo

anoonaa / printf Goto Github PK

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

Custom printf function , for the ALX Software Engineering Programme

C 100.00%
alx-africa alx-holberton-software-engineering alx-low-level-programming c functions low-level-programming printf

printf's Introduction

printf()

The printf() function, which is short for “print formatted,” is a fundamental function in C , It is part of the standard input/output library (stdio.h) it is primarily used for outputting formatted text on the console . With printf, you can display various data types such as :

integers, floating-point numbers, characters, and strings

and can allow formatting in numerous ways.

Resource :

https://www.academia.edu/10297206/Secrets_of_printf_

Parameters

  • formatted_string: It is a string that specifies the data to be printed. It may also contain a format specifier to print the value of any variable such as a character and an integer.
  • arguments_list: These are the variable names corresponding to the format specifier

Supported Format Specifiers

Format specifiers begin with '%' and can include optional flags, length modifiers, and conversion characters.

Available Specifiers

Specifier Description
c Character
d or i Signed decimal integer
s String of characters
b Binary representation
o Octal representation
u Unsigned decimal integer
x Unsigned hexadecimal integer (lowercase)
X Unsigned hexadecimal integer (uppercase)
p Pointer address
r Reverse string
R ROT13 encrypted string
S String with special characters replaced by ASCII values
% Literal '%' character

Flags and Length Modifiers

Flags (+, (space), #, 0) and length modifiers (l, h) modify the behavior of specifiers.

Usage

  • Compile using : $ gcc -Wall -Werror -Wextra -pedantic -std=gnu89 *.c

  • Simply include the main.h header file in your own program and call the custom printf function with the desired format string and any necessary arguments.

Example usage:
_printf("Hello %s\n", "World");
This will output:

Hello World

Authors

  • Anoona Sithole
  • Shumirai Sithole

printf's People

Contributors

anoonaa 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.