-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_chardelete.c
37 lines (34 loc) · 1.2 KB
/
ft_chardelete.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_chardelete.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: pferry <pferry@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/03/04 17:09:50 by pferry #+# #+# */
/* Updated: 2014/03/04 17:22:51 by pferry ### ########.fr */
/* */
/* ************************************************************************** */
#include "shell.h"
char *ft_chardelete(char *line, int i)
{
char *new;
int j;
j = 0;
new = (char *)malloc(sizeof(char) * ft_strlen(line));
if (new == NULL)
return (NULL);
while (j < i - 1)
{
new[j] = line[j];
j++;
}
while (line[j + 1])
{
new[j] = line[j + 1];
j++;
}
new[j] = '\0';
free(line);
return (new);
}