elianrc / ft_printf

Recode of libc's 'printf' function.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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.


Languages

Language:C 96.4%Language:Makefile 3.6%