My while loop has become an infinite one inspite of using decrement operator. Could you please explain why is that so? Isn't it supposed to come out of the while loop once the condition becomes false?
    # include<bits/stdc++.h> 
    using namespace std; 
    const int MAX_CHAR = 26; 
    // Function to print the string 
    void printGrouped(string str) 
    { 
        int n = str.length(); 
        // Initialize counts of all characters as 0 
        int  count[MAX_CHAR] = {0};           
        for (int i = 0 ; i < n ; i++) 
            count[str[i]-'a']++; 
        for (int i = 0; i < n ; i++) 
        {                
            while (count[str[i]-'a']--)
                cout << str[i];
        } 
    } 
    // Driver code 
    int main() 
    { 
        string str = "applepp";           
        printGrouped(str); 
        return 0; 
    } 
 
     
     
    