Skip to content

mdallen5393/holbertonschool-printf

Repository files navigation

0x12. C - printf

Description:

C implementation of the standard library function printf. Printf is used to print formatted strings to standard output. It is a variadic function that takes a format string followed by a number of optional variables and returns the number of characters printed.

Instructions:

Printing string literals:

Format: _printf("string to print\n"); Description: Prints whatever is inserted between double-quotes. Use the backslash character () to print special characters such as '\n' to print a newline character.

Using Format Specifiers:

Format specifiers are characters prepended with a percent (%) symbol. The function requires one optional variable per format specifier, with the exception of the "%%" specifier, which simply prints a percent symbol (similar to "%").

Printing Integer Variables:

Format Specifier: %i or %d Ex 1: _printf("numA = %i\n", 32);

numA = 32

Ex 2: _printf("A = %d, B = %i\n", numA, numB);

A = 10, B = 13

Ex 3: _printf("The temperature is %i degrees C\n", -18);

The temperature is -18 degrees C

Printing Character Variables:

Format Specifier: %c Ex 1: _printf("You chose option %c!\n", op);

You chose option e!

Ex 2: `_printf("Your grade is an %c\n", 'B');

Your grade is a B

Printing String Variables:

Format Specifier:%s Ex 1: _printf("Hello, %s!\n", name);

Hello, Matthew!

Ex 2: _printf("Hello, %s, my name is %s.\n", name, "Nick");

Hello, Matthew, my name is Nick.

Authors:

Nicholas French | github - MetaFrench

Matthew Allen | github - mdallen5393

About

Implementation of the printf library function

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages