/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* test_printf.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: lalgarra +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/10/15 18:54:32 by lalgarra #+# #+# */ /* Updated: 2025/10/15 19:27:35 by lalgarra ### ########.fr */ /* */ /* ************************************************************************** */ #include "libftprintf.h" #include #include #include static char *get_begin(void) { return "%s printf() output: [BEGIN]"; } static char *get_ftbegin(void) { return "%s ft_printf() output: [BEGIN]"; } static char *get_end(void) { return "[END]; returns: %i\n"; } static void call_printf(const char *prefix, const char *sfmt, ...) { int ret; va_list args; printf(get_begin(), prefix); va_start(args, sfmt); ret = vprintf(sfmt, args); va_end(args); printf(get_end(), ret); fflush(stdout); } static void test01() { char prefix[128]; char sfmt[128]; char arg1[128]; int ret; strcpy(prefix, "test01: "); strcpy(sfmt, "Hola %s Mundo"); strcpy(arg1, "Es%sto es una \xfa prueba"); call_printf(prefix, sfmt, arg1); printf(get_ftbegin(), prefix); fflush(stdout); ret = ft_printf(sfmt, arg1); printf(get_end(), ret); fflush(stdout); } int main(void) { test01(); return (0); }