maxishell
Implementation of a shell for Linux-like systems
Loading...
Searching...
No Matches
ft_strjoin.c File Reference
#include "libft.h"
Include dependency graph for ft_strjoin.c:

Go to the source code of this file.

Functions

char * ft_strjoin (char const *s1, char const *s2)
 

Function Documentation

◆ ft_strjoin()

char * ft_strjoin ( char const *  s1,
char const *  s2 
)

Definition at line 23 of file ft_strjoin.c.

24{
25 size_t len;
26 char *pt;
27 char *result;
28
29 if (!s1 || !s2)
30 return (NULL);
31 len = ft_strlen(s1) + ft_strlen (s2) + 1;
32 if (len == 0)
33 return (NULL);
34 pt = (char *)malloc(sizeof(char) * len);
35 if (!pt)
36 return (NULL);
37 result = pt;
38 while (*s1)
39 *pt++ = *s1++;
40 while (*s2)
41 *pt++ = *s2++;
42 *pt = '\0';
43 return (result);
44}
size_t ft_strlen(const char *s)
Definition ft_strlen.c:15

References ft_strlen().

Referenced by append_literal(), builtin_cd(), builtin_export(), env_to_array(), ft_strjoin_free(), generate_prompt_string(), handle_numeric_error(), and relative_path_handle().

Here is the call graph for this function:
Here is the caller graph for this function: