Skip to content

elianrc/ft_printf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

60 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

ft_printf_logo

This project is a recode of libc's 'printf' function in accordance with the 42 code norm.

๐ŸŽฏ Subject

You can see the subject pdf here.

  • Recode libc's 'printf' function.
  • It manages the following conversion: cspdiuxX%
  • It also manages any combination of the following flags: -0.*
  • Example:
  #include "../2.ft_printf/ft_printf.h"
  #include <stdio.h>

  int main(void)
  {
    int num, hex = 20124;
    int *ptr = &num;
    char *str = "EXAMPLE";

    ft_printf("Integer: %d\n", num);
    ft_printf("Hexadecimal: %0*x\n", 10, hex);
    ft_printf("Pointer address: %p\n", ptr);
    ft_printf("String: |%-15s|\n", str);

    return (0);
  }
  • Output:
  Integer: 32767
  Hexadecimal: 0000004e9c
  Pointer address: 0x7fff2a63b36c
  String: |EXAMPLE        |

๐Ÿ”ง Usage

The makefile creates a library called "libftprintf.a" that contains ft_printf. You can compile a program with "libftprinf.a".

  • Example:
   make && make clean
   gcc main.c libftprintf.a

๐Ÿชฒ Debugging

LLDB is a powerful tool that helped me debug this project, specially the GUI. Here is how you can run it:

  • First, modify your makefile so it compiles with '-g3'.
	@gcc -g3 -Wall -Wextra -Werror -I$(INCLUDES) -c $(SRCS)
  • At compilation time, compile with '-g3' too.
gcc -g3 main.c libftprintf.a
  • Then run the following command consecutively:
lldb a.out
b main
run
gui

In the GUI, use 's', 'tab', 'space' & 'o' to explore your program step by step.

๐ŸฅŠ Testers

๐Ÿ“š Resources

I had many sources of information but the main ones would be:

โœ”๏ธ Moulinette

result_by_mounlinette

๐Ÿ˜„ Special Thanks

I want to thank God in the first place for all the special people that helped me through this project:

Thanks so much. It would have been very different without your help.

SOLI DEO GLORIA

About

Recode of libc's 'printf' function.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published