ft_strjoinf.c 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* ft_strjoinf.c :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: mazimi <mazimi@student.42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2014/11/10 17:27:47 by mazimi #+# #+# */
  9. /* Updated: 2017/01/30 17:06:22 by mazimi ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "../libft.h"
  13. /*
  14. ** p: free strings
  15. ** 1 for first string, 2 for snd string
  16. ** 3 to free both strings
  17. */
  18. char *ft_strjoinf(char const *s1, char const *s2, int p)
  19. {
  20. char *str;
  21. if ((str = ft_strjoin(s1, s2)) == NULL)
  22. return (NULL);
  23. (p == 1 || p == 3) ? ft_strdel((char **)&s1) : ft_strdel((char **)&s2);
  24. if (p == 3)
  25. ft_strdel((char**)&s2);
  26. return (str);
  27. }