-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_sprintf.c
More file actions
33 lines (29 loc) · 1.21 KB
/
ft_sprintf.c
File metadata and controls
33 lines (29 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_sprintf.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: hbooke <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/10/29 00:59:59 by hbooke #+# #+# */
/* Updated: 2020/10/29 01:00:48 by hbooke ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include "utils.h"
#include <stdarg.h>
#include <unistd.h>
int ft_sprintf(char *buf, const char *fmt, ...)
{
va_list ap;
int len;
if (buf)
buf[0] = 0;
if (!buf || !ft_strcmp("%", fmt))
return (0);
va_start(ap, fmt);
len = ft_internal_snprintf(buf, (size_t)-1, fmt, &ap);
va_end(ap);
buf[len] = 0;
return (len);
}