diff options
Diffstat (limited to '')
-rw-r--r-- | src/c_utils.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/c_utils.c b/src/c_utils.c index 3eb7f4d..6621a1a 100644 --- a/src/c_utils.c +++ b/src/c_utils.c @@ -45,6 +45,37 @@ uint16_t } char +*c_insert_char(char *str, + char c, + t_caps *tcaps) +{ + size_t i; + size_t j; + size_t len; + char *dst; + + i = 0; + j = 0; + len = ft_strlen(str) + 2; + if (!(dst = (char*)malloc((len) * sizeof(char)))) + return (NULL); + while (i < len) + { + if (i == tcaps->cpos) + dst[i++] = c; + else + { + dst[i] = str[j]; + i++; + j++; + } + } + dst[len] = '\0'; + ft_memdel((void*)&str); + return (dst); +} + +char *c_delchar(char *str, uint16_t cpos) { |