Initial commit
This commit is contained in:
commit
6fa86c0a44
2 changed files with 165 additions and 0 deletions
68
test_printf.c
Normal file
68
test_printf.c
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* test_printf.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: lalgarra <lalgarra@student.42madrid.com> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2025/10/15 18:54:32 by lalgarra #+# #+# */
|
||||
/* Updated: 2025/10/15 19:27:35 by lalgarra ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "libftprintf.h"
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue