print_string.c
1 /* ************************************************************************** */ 2 /* */ 3 /* ::: :::::::: */ 4 /* print_string.c :+: :+: :+: */ 5 /* +:+ +:+ +:+ */ 6 /* By: gychoi <gychoi@student.42seoul.kr> +#+ +:+ +#+ */ 7 /* +#+#+#+#+#+ +#+ */ 8 /* Created: 2022/09/09 21:05:36 by gychoi #+# #+# */ 9 /* Updated: 2022/09/13 14:26:31 by gychoi ### ########.fr */ 10 /* */ 11 /* ************************************************************************** */ 12 13 #include "ft_printf.h" 14 15 int print_string(char *str) 16 { 17 int printed; 18 int len; 19 20 if (str == 0) 21 { 22 printed = (int)write(1, "(null)", 6); 23 if (printed < 0) 24 return (-1); 25 return (printed); 26 } 27 len = 0; 28 while (str[len] != 0) 29 len++; 30 printed = (int)write(1, str, len); 31 if (printed < 0) 32 return (-1); 33 return (printed); 34 }