-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprint_str_or_null.c
More file actions
30 lines (28 loc) · 1.23 KB
/
print_str_or_null.c
File metadata and controls
30 lines (28 loc) · 1.23 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* print_str_or_null.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mhegedus <mhegedus@student.42vienna.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/11/18 15:08:47 by mhegedus #+# #+# */
/* Updated: 2024/11/19 11:51:10 by mhegedus ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft/libft.h"
#include <unistd.h> // for STDOUT_FILENO
// prints string to stdout or the string "(null)" if *s == NULL
// returns number of chars printed
int print_str_or_null(char *s)
{
if (s == NULL)
{
ft_putstr_fd("(null)", STDOUT_FILENO);
return (ft_strlen("(null)"));
}
else
{
ft_putstr_fd(s, STDOUT_FILENO);
return (ft_strlen(s));
}
}