Skip to content

RanniSch/ft_printf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ft_printf

The goal of this project is to recode printf() with a variable number of arguments.

For example, the function can handle the following conversions: cspdiuxX%

For each conversion required by the subject, there's a function that converts the argument and returns the numer of bytes writed:
%c print a single character.
%s print a string of characters.
%p The void * pointer argument is printed in hexadecimal.
%d print a decimal (base 10) number.
%i print an integer in base 10.
%u print an unsigned decimal (base 10) number.
%x print a number in hexadecimal (base 16).
%% print a percent sign.

How to run the code

Enter the repository with cd and add a "main.c" with touch main.c.
For example copy paste the following code into main:

#include "ft_printf.h"

int	main(void)
{
    long int     hd_big;
    long int     hd_small;
    char	*name;
	char	n[8] = "Heather";
    name = &n[0];
    hd_big = 590;
    hd_small = 590;
	ft_printf("Hexa big %X and small %x. Position %p \n", hd_big, hd_small, name);
    char	*name2;
	char	n2[10] = "Christian";
	char	chr;
	int		age;
    int     base;
    int     pos;
    long int     hd_big2;
    long int     hd_small2;
	name2 = &n2[0];
	chr = 'a';
	age = 24;
    base = 12;
    pos = 160;
    hd_big2 = 590;
    hd_small2 = 590;
	ft_printf("My name is %s with an %c saved at: %p. Hexa big %X and small %x. Positive: %u, age %d, %% and %i.\n", name2, chr, name2, hd_big2, hd_small2, pos, age, base);  
	return (0);
}

Run make (to run the Makefile that will compile the source code and create the library).
You should now see a libftprintf.a file and some object files (.o).
To clean up (removing the .o files), call make clean.

Compile your .c files with gcc using gcc main.c libftprintf.a. You need to include the libftprintf.a to tell the file which library it is using.

Now you can run the code using ./a.out.

ft_printf-01

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors