There are several bugs in your code.
while(str[i]!='\0')
{
str[j]=str[i];
i=i+2;
j++;
}
By incrementing
i
in steps of 2 you will run over the null terminator at the end. And that probably produces you segmentation fault.
while(j<len)>
{
str[j]="a";
j++;
}
You certainly meant
str[j] = 'a';
[EDIT]
And there is a third one:
for(i=0;strlen(str);i++)
This loop runs forever.