Unable to find out error in my code

I have understood the code you have sent me but i am unable to find the bug in my code due to which there is run time error. Please reply accordingly.

Plz send your code by saving on ide so that we could check it.

my first approachhttps://ide.codingblocks.com/s/140459

Harsh, plz change your approach , make a frequency array and then based on that have this line of code as ,
int max=0;
char result;
int freq[27]={0};
for(int i=0;i<len;i++)
{
freq[S[i]-97]++;
if(max<freq[S[i]-97])
{
max=freq[S[i]-97];
result=S[i];
}
}