-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror.c
executable file
·42 lines (39 loc) · 1.37 KB
/
error.c
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
34
35
36
37
38
39
40
41
42
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* error.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rbenjami <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/05/06 14:46:33 by rbenjami #+# #+# */
/* Updated: 2014/05/14 17:25:10 by rbenjami ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdarg.h>
#include <stdio.h>
#include "libft.h"
int error(const char *msg, ...)
{
va_list ap;
va_start(ap, msg);
while (*msg)
{
if (*msg == '%')
{
msg++;
if (*msg == '%')
ft_putchar_fd('%', 2);
else if (*msg == 'c')
ft_putchar_fd(va_arg(ap, int), 2);
else if (*msg == 's')
ft_putstr_fd(va_arg(ap, char*), 2);
else if (*msg == 'd')
ft_putnbr_base_fd(va_arg(ap, int), 10, 2);
}
else
ft_putchar_fd(*msg, 2);
msg++;
}
va_end(ap);
return (-42);
}