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 38 39 40 41 42 43 44 45 46 47 48 49
| #include <stdio.h>
#include <stdlib.h>
void my_strcpy(char *source, char *recpient)
{
int i;
i = 0;
while (source[i])
{
puts("toto");
recpient[i] = source[i];
i++;
}
}
void sup_char(char *str, int position)
{
int i;
int j;
char *temp;
temp = malloc(sizeof (*temp) * strlen(str));
j = 0;
i = 0;
while (str[i])
{
if (i != position)
{
temp[j] = str[i];
j++;
}
i++;
}
str[0] = '\0';
my_strcpy(temp, str);
puts(str);
free(temp);
}
int main(int argc, char *argv[])
{
char *str;
//= "je suis la";
str = malloc(50);
str = "toto";
sup_char(str, 1);
system("PAUSE");
return 0;
} |
Partager