Returning char array

I want to return a char array to the main() function, but its returning garbage value.

#include<stdio.h>
//#include<conio.h>
#include<string.h>

char* strtrmm();

int main()
{

char str1[100],c1[100];
printf("\n Enter the string:");
 gets(str1);

//strtrmm(str1);
printf("%s",strtrmm(str1));     //gives garbage value

//printf("%s",c1);
}

char* strtrmm( char str1[])
{
 char str[100],sub[100],s1[100],s11[100],*c1="a";
 int i,i1=0,j,k,l,f=0,g=0,m,h,v,count=0;
 
 

    
    strcpy(str,str1);

 printf("\n Enter the substring:");
 gets(sub);

 l=strlen(sub);
 m=strlen(str);

 printf("%d %d",l,m);
 for(i=0;str!='\0';i++)
 {
  k=i;
  j=0;
  while(sub[j]!='\0')
  {
   if(str[k]==sub[j])
   {
    g++;
    if(g==l)
    {
     f=1;
     h=i;
    }
   }
   else if(str[k]!=sub[j])
   {
    break;
   }
   j++;
   k++;
  }
 }
 if(f==1)
 {
  printf("\n sub string is found\n\n\n");
  for(i=0;i<m;i++)
  {
   if(i<h)
    {
    printf("%c",str);
    s1[i1]=str;
    i1++;
    count++;
    }    
   else if(i>h&&i<(h+l))
    continue;
   else if(i>=(h+l))
    {
    printf("%c",str);
    s1[i1]=str;
    i1++;
    count++;
    }
  }
printf("\n %d \n",count);
 }
 else if(f==0)
 {
  printf("\n substring not found:");
 }

/*    for(i=0;i<count;i++)
    {
    s11=s1;

    }
*/

c1=s1;


printf(" ret:%s \n ",c1);
return c1;
// getch();
 //return(0);
}

At the very least, you should provide a description of what the program does, along with sample input, current (incorrect) output, and the desired output.

It would also help a great deal if you used a reasonable amount of indentation to highlight your code's structure.

Regards,
Alister

s1 is a local variable. It ceases to exist when your function returns.

Usually, such a function would accept str1 as an argument instead of declaring it locally -- that would let you pass valid memory INTO the function. It would remain valid after strtrmm returns.

char *strtrmm(const char *in, char *str1);

int main(void) {
        char in[100]="some string";
        char out[100];

        printf("%s\n", strtrmm(in, out));
}

This would effectively be the same as

strtrmm(in, out);
printf("%s\n", out);

You should end your printf with \n if you want to actually see it, since without it you'll get all your strings jammed on one line and not even see them until the program quits.