Prototype

int ft_printf(const char *, ...);

Program name

  • libftprintf.a

Turn in files

  • *.c, *.h, Makefile

Makefile

  • all, clean, fclean, re, bonus

External functs.

  • malloc, free, write, va_strat, va_arg, va_copy, va_end

Description

  • Write a library that contains ft_printf, a function that will mimic the real printf

Comment

  • libft 사용 가능
  • printf를 최대한 똑같이 동작하게 만들기

선행지식

1. stdarg.h 관련 지식

2. printf

목표

  • printf 함수와 최대한 똑같이 동작하게 만들기

구현 방법

  1. format에서 받은 문자열을 저장한다.
  2. format[i]가 문자열일 경우 그대로 출력한다.
  3. format[i]에 % 문자가 있을 때, flag, width, precision 등을 체크한다.
  4. 해당 기호에 맞는 출력형식으로 출력한다.
  5. 2번으로 돌아가 반복한다.

구현해야 하는 인자

flags : '-0.*'

width

precision

type : cspdiuxX%

 

  • 이때는 아직 열심히 정리를 하지 않았을 때라 함수는 깔끔하게 잘 짠 거 같은데 남아있는 자료가 하나도 없다... 평소에 열심히 정리좀 해둘걸 ㅜ
  • 그래도 딱 필요한 것만 모아두었다 ㅎ

+ Recent posts