i have written 3 general functions regarding trims

check this
Code:
#include <stdio.h>
#include <string.h>
#include <malloc.h>


void trimLeft(char [],char);
void trimRight(char [],char);
void trim(char[],char);

void trimRight(char string[],char what){//what=the char to remove
    int len= strlen(string)-1;
    while (string[len-1]==what){
         len--;
     }
     string[len]= '\0';
}
void trimLeft(char string[],char what){
    int i=0,len=0,len1=0,size=0;
    len=strlen(string);
     while (string[len1]==what){
         len1++;
     }
     size=len-len1;
     char * rest=NULL;
     if (len1>0){
            rest=(char *)malloc((size+1)*sizeof(char));
          for (i=len1;i<len;i++){
                rest[i-len1]=string[i];
          }
          rest[size]='\0';
          strcpy(string,rest);
    }
}


void trim(char string[],char what){
   trimRight(string,what);
   trimLeft(string,what);
}

int main(){
char test1[]="+++++++++++++++test1+++++++++++++++";
printf("\nbefore trimRight:<%s>",test1);
trimRight(test1,'+');
printf("\nafter trimRight:<%s>",test1);
printf("\n");

char test2[]="@@@@@@@@@@@@test2------------";
printf("\nbefore trimLeft:<%s>",test2);
trimLeft(test2,'@');
printf("\nafter trimLeft:<%s>",test2);
printf("\n");

char test3[]="--------------test3------------";
printf("\nbefore trim:<%s>",test3);
trim(test3,'-');
printf("\nafter trim:<%s>",test3);
printf("\n");
getchar();
return 0;
}