GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - CrispthoAlex/printf: The printf project is the coding of a function named "_printf()" that imitates to "printf()"

BranchesTags
Open more actions menu

Latest commit

 

History

49 Commits
49 Commits

Folders and files

NameName
Last commit message
Last commit date
.gitignore
.gitignore
 
 
README.md
README.md
 
 
_printf.c
_printf.c
 
 
_putchar.c
_putchar.c
 
 
holberton.h
holberton.h
 
 
man_3_printf
man_3_printf
 
 
task_0.c
task_0.c
 
 
task_1.c
task_1.c
 
 
task_14.c
task_14.c
 
 
task_15.c
task_15.c
 
 
task_3.c
task_3.c
 
 
task_4.c
task_4.c
 
 
task_6.c
task_6.c
 
 
task_7.c
task_7.c
 
 

Repository files navigation


printf Project

March / 2020


The printf project is the coding of a function named "_printf()" that imitates to "printf()". This C language function is a powerful device for printing numbers and other things stored in variables. Located in the stdio.h library. You can find some of the basic features and functions in the manual 3 of "printf()".

_printf() is a function that performs formatted output conversion and print data, but what means that. Please, read about the variadic functions and go back later.

Its prototype was defined following:

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

Where format contains a string that will be print. This strings is composed by n arguments that will be replace by n tags definied inside the string.

Following, the variadic function format tags prototype is:

   %[flags][length]specifier

Return value is the amount of chars printed (program successfully), see this tables:

Specifier Output
c Character
d or i Signed decimal integer
s String of characters
b unsigned decimal integer in binary
u unsigned decimal integer
o unsigned decimal integer in octal
x unsigned decimal integer in hexadecimal lower case
X unsigned decimal integer in hexadecimal upper case
p address as hexadecimal (base 16) lower case
S String including Non printable characters
r reversed string
R string in rot13
% Character

Examples

  1. Printing the string "Example":
  • Use: _printf("%s", "Example");
  • Output: Holberton.
  1. print the singular character 'e':
  • Use: _printf("%c", e);
  • Output: e
  1. Print the decimal number 5:
  • Use: _printf("%d", 5);
  • Output: 5
  1. Print the int number -98:
  • Use: _printf("%i", -98);
  • Output: -98

File Functions

_printf.c

Our printf function the Performs formatted Output Conversion And Print Data.


holberton.h

Header file. Include all prototypes functions used


Task files

  • task_0.c

int print_c(va_list c) /* prints a char */

int print_s(va_list s) /* prints a string */

  • task_1.c

int print_i(va_list i) /* prints an integer */

int print_d(va_list d) /* prints a decimal */

  • task_3.c

int print_b(va_list b) /* prints an unsigned integer in binary (base 2) */

  • task_4.c

int print_u(va_list u); /* prints an unsigned integer */

int print_o(va_list o); /* prints an unsigned integer in octal (base 8) */

int print_x(va_list x); /* prints an unsigned integer in hexadecimal (base 16) */

int print_X(va_list X); /* prints an unsigned integer in hexadecimal (base 16) */

  • task_6.c

static unsigned long power(unsigned int x, unsigned int y) /* calculates an exponent */

int print_p(va_list p); /* prints a hexadecimal address (0x base 16) */

  • task_7.c

int print_S(va_list S); /* prints a string with Non printable characters (ASCII code value hexadecimal) */

  • task_14.c

print_r(va_list r); /* prints a reverse string */

  • task_15.c

int print_R(va_list R); /* prints a string in rot13 */

Return values

On success returns an integer number of symbols printed not counting \0 for the string.

On failure returns error number (-1)


Flowchart

  • _printf

  • verify_type

Team Project

It's a collaboration between Crispthofer Rincon & Santiago Martinez, students (from cohort 11 - january 2020) of Software Engineering at Holberton School

Waiting for you in Holberton School Campus Cali, Colombia

About

The printf project is the coding of a function named "_printf()" that imitates to "printf()"

Topics

copy-printfholbertonprintfprototypes-functionsvariadic-functionvariadic-functions

Resources

Readme
Activity

Stars

5 stars

Watchers

1 watching

Forks

2 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.