summaryrefslogtreecommitdiffstats
path: root/src/c_utils.c
diff options
context:
space:
mode:
authorsalad <fmoenne-@student.le-101.fr>2020-09-09 14:10:09 +0200
committersalad <fmoenne-@student.le-101.fr>2020-09-09 14:10:09 +0200
commitca3cc66deebc4dc5ac52b14ed099c05f416ccc7f (patch)
tree4737eb8d8523c682eb13e491ab3f85dad5d86af0 /src/c_utils.c
parentclean, ca fait ziz (diff)
download42-minishell-ca3cc66deebc4dc5ac52b14ed099c05f416ccc7f.tar.gz
42-minishell-ca3cc66deebc4dc5ac52b14ed099c05f416ccc7f.tar.bz2
42-minishell-ca3cc66deebc4dc5ac52b14ed099c05f416ccc7f.tar.xz
42-minishell-ca3cc66deebc4dc5ac52b14ed099c05f416ccc7f.tar.zst
42-minishell-ca3cc66deebc4dc5ac52b14ed099c05f416ccc7f.zip
insert a char try it
Diffstat (limited to 'src/c_utils.c')
-rw-r--r--src/c_utils.c31
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)
{