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

Go to the source code of this file.

Functions

char * ft_substr (char const *s, unsigned int start, size_t len)
 

Function Documentation

◆ ft_substr()

char * ft_substr ( char const *  s,
unsigned int  start,
size_t  len 
)

Definition at line 27 of file ft_substr.c.

28{
29 char *new_str;
30 size_t i;
31 size_t j;
32 size_t size;
33
34 size = ft_strlen(s) - start;
35 if (start > ft_strlen(s))
36 size = 0;
37 else if (size > len)
38 size = len;
39 new_str = (char *)malloc(size + 1);
40 if (!s || !new_str)
41 return (0);
42 i = start;
43 j = 0;
44 while (i < ft_strlen(s) && j < len)
45 new_str[j++] = s[i++];
46 new_str[j] = '\0';
47 return (new_str);
48}
size_t ft_strlen(const char *s)
Definition ft_strlen.c:15

References ft_strlen().

Referenced by append_literal(), ev_loop(), expand_variable(), and post_process_command_args().

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