Giter Club home page Giter Club logo

ft_printf's Introduction

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

ft_printf's People

Contributors

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