Unable to understand editorial

i had successfully submitted this question using my approach but when i opened the editorial i understood the concept they used but was unable to understand the code mainly the frequency array part.

here is the editorial code

#include
using namespace std;
int main() {
char str[1000];
int freq[256];
cin>>str;

for(int x=0;str[x]!='\0';x++){
    freq[str[x]]++;
}
int ans=0;
char ch;
for(int x=0;x<256;x++){
    if(freq[x]>0){
        if(freq[x]>ans){
            ans=freq[x];
            ch=char(x);
        }
    }
}
cout<<ch;

}

please explain this to me and also tell how can a character be the index of an array

hi @Parmeet-Kalsi-1631789033630118 each character is associated with an ASCII value which is a numeric value. Computers can read only binary so we need a numerical association with each character to process it. http://www.asciitable.com/ here is a list of all the ascii characters.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.