title: Print characters and their frequencies in order of occurrence in a given string but i cant' understand line "freq[str[i] - 'a']++; "
body: <p><a href="https://www.geeksforgeeks.org/print-characters-frequencies-order-occurrence/" rel="nofollow noreferrer"><strong>Print characters and their frequencies in order of occurrence</strong></a></p>
  
  <p>This is the whole program link if you want to know other details</p>
  
  <p>Below is program</p>
  
  <pre><code>void printCharWithFreq(string str) 
    { 
  
  int n = str.size(); 
  
  // 'freq[]' implemented as hash table 
  int freq[SIZE]; 
  
  // initialize all elements of freq[] to 0 
  memset(freq, 0, sizeof(freq)); 
  
  // accumulate freqeuncy of each character in 'str' 
  for (int i = 0; i &lt; n; i++) 
      freq[str[i] - 'a']++;   //**cannot understand this line**
  
  // traverse 'str' from left to right 
  for (int i = 0; i &lt; n; i++) { 
  
      // if frequency of character str[i] is not 
      // equal to 0 
      if (freq[str[i] - 'a'] != 0) { 
  
          // print the charcter along with its 
          // frequency 
          cout &lt;&lt; str[i] &lt;&lt; freq[str[i] - 'a'] &lt;&lt; " "; 
  
          // update frequency of str[i] to 0 so  
          // that the same character is not printed  
          // again 
          freq[str[i] - 'a'] = 0; 
      } 
    } 
  </code></pre>
  
  <p>} </p>