1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

Can't stop endless loop...

Discussion in 'C++' started by tvred, Mar 24, 2010.

  1. tvred

    tvred New Member

    Joined:
    Mar 22, 2010
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Hello, I have this problem and I can't stop it looping only 'A'...it won't print 'A' through 'Z'?...

    Code:
    #include<iostream>
    #include<string>
    using namespace std;
    
    
    
    int main()
    {
        cout << "here is a list" << endl;
        char letter = 'A';
    
        while (letter <= 'Z')
        {
            cout << letter << '\t' << static_cast<int>(letter) << endl;
        }
    
        return 0;
    
    }
    
     
  2. virxen

    virxen New Member

    Joined:
    Nov 24, 2009
    Messages:
    387
    Likes Received:
    90
    Trophy Points:
    0
    letter is always equal to 'A' that's why it never stops.
    you must increase its value by one inside the while.

    change this
    Code:
            cout << letter << '\t' << static_cast<int>(letter[COLOR=Red]++[/COLOR]) << endl;
    
     

Share This Page