I am trying to remove two consecutive duplicate elements from the string.I am getting segmentation fault in the line 16 .even the commented 17th line also get me the same error.
dont worry about my logic of my program.it may be wrong...but i am struck with this error..help me out...explain why i am getting this error
#include <stdio.h>
#include <stdlib.h>
int main()
{
char *st="fvvbbyyr";
int i=0,j,len;
for(len=0;st[len]!='\0';len++);
for(i=0;i<len;i++)
{
if(st[i]==st[i+1])
{
for(j=i+2;j<len;j++)
{
*(st+j-2)=*(st+j);
//st[j-2]=st[j];
}
len = len-2;
i=-1;
}
}
return 0;
}