Mistake in my caode

what is the mistake in my code

hey @shiva57reddy, please share the code saved in CB ide.

#include
#include
using namespace std;
int max_c(string s);
int main()
{
string s;
getline(cin,s);

 cout << max_c(s);

}

int max_c(string s)
{
int a[s.length()] = {0};

int i = 0;

 while(s[i] != '\0')
 {
     for(int j = i;j < s.length();j++)
       {   if(s[j] == s[i])
            ++a[i];

 }
 ++i;

 }

int max1 = a[i];
while(i >= 0)
{
max1 = max(max1,a[i]);
i–;
}

return max1;
}

hey @shiva57reddy, please save the code here https://ide.codingblocks.com/ and share the URL. Because code gets mismatched here when you share it mesage.

hey @shiva57reddy, you i variable needs to start from position less when you are finding the max value. Moreover you need to print the max freq character not frequency of maximum character.
Here is your updated code https://ide.codingblocks.com/s/107351