-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_string_specifiers.c
More file actions
47 lines (43 loc) · 1.39 KB
/
ft_string_specifiers.c
File metadata and controls
47 lines (43 loc) · 1.39 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_string_specifiers.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: cwenz <cwenz@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/04/12 07:54:48 by cwenz #+# #+# */
/* Updated: 2023/04/27 15:05:27 by cwenz ### ########.fr */
/* */
/* ************************************************************************** */
#include "ft_printf.h"
/**
** @brief Writes a single char to standard output
** @param c The char to write
** @return Returns an int 1
*/
int ft_putchar(char c)
{
return (write(1, &c, 1));
}
/**
** @brief Writes a string to standard output
** @param str The string to write
** @return The length of the string
*/
int ft_putstr(char *str)
{
int i;
i = 0;
if (!str)
{
i += ft_putstr("(null)");
return (i);
}
while (str[i])
{
if (ft_putchar(str[i]) < 0) // Check if write fails
return (-1);
i++;
}
return (i);
}