minishell
ft_substr.c File Reference
#include <stddef.h>
#include "ft_string.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 16 of file ft_substr.c.

17 {
18  if (s == NULL)
19  return (NULL);
20  if (len == 0 || ft_strlen(s) <= start)
21  return (ft_strdup(""));
22  return (ft_strndup(s + start, len));
23 }
char * ft_strdup(const char *s1)
Definition: ft_strdup.c:16
char * ft_strndup(const char *s1, size_t n)
Definition: ft_strndup.c:18
size_t ft_strlen(const char *s)
Definition: ft_strlen.c:15
Here is the call graph for this function:
Here is the caller graph for this function: