-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstring_specifiers.c
More file actions
50 lines (48 loc) · 884 Bytes
/
Copy pathstring_specifiers.c
File metadata and controls
50 lines (48 loc) · 884 Bytes
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
43
44
45
46
47
48
49
50
#include "main.h"
#include <stdio.h>
#include <stdarg.h>
#include <unistd.h>
/**
* ctype - Prints character type
* @args: A va_list containing the character to print
*
* Return: 1.
*/
int ctype(va_list args)
{
char letter = va_arg(args, int);
write(1, &letter, 1);
return (1);
}
/**
* mtype - Prints a character from a variadic argument list
* @args: The variadic argument list containing the character
*
* Return: 1.
*/
int mtype(va_list args)
{
(void)args;
_putchar('%');
return (1);
}
/**
* stype - Prints string type
* @args: A va_list containing the string to print
*
* Return: lenght.
*/
int stype(va_list args)
{
char *str = va_arg(args, char *);
char *nil_str = "(null)";
int lenght;
if (str == NULL)
{
write(1, nil_str, ft_strlen(nil_str));
return (ft_strlen(nil_str));
}
lenght = ft_strlen(str);
write(1, str, lenght);
return (lenght);
}