|
@@ -113,9 +113,9 @@ char* ltrim(char* str, char mask){
|
|
|
return str;
|
|
|
}
|
|
|
//Sinon creation nouvelle chaine
|
|
|
- res = malloc(sizeof(char) * (strlen(str) - cmpt));
|
|
|
- for(int i = cmpt; i < strlen(str); i++){
|
|
|
- res[i] = str[cmpt++];
|
|
|
+ res = malloc(sizeof(char) * (strlen(str) - cmpt + 1));
|
|
|
+ for(int i = 0, j = cmpt; i < (strlen(str) - cmpt); i++, j++){
|
|
|
+ res[i] = str[j];
|
|
|
}
|
|
|
//Retour nouvelle chaine
|
|
|
return res;
|
|
@@ -135,7 +135,7 @@ char* rtrim(char* str, char mask){
|
|
|
}
|
|
|
cmpt++;
|
|
|
//Sinon creation nouvelle chaine
|
|
|
- res = malloc(sizeof(char) * (cmpt + 1));
|
|
|
+ res = malloc(sizeof(char) * (cmpt + 2));
|
|
|
for(int i = 0; i < cmpt; i++){
|
|
|
res[i] = str[i];
|
|
|
}
|