title: C++ display char while loop rows
body: <p>I am very new to programming, so I apologize if this question seems absurdly simple.  I am working on some extra questions in the current chapter of my C++ book.  I have actually found a correct answer to the problem, but while doing so, I ran into a situation that is driving me crazy because I can't figure out WHY one particular solution works and another one doesn't.</p>
  
  <p>So, the problem asks to print the ASCII values between 32 and 127 in a few rows with 16 characters per row.  The solution I have come to (that works correctly) is this:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int main()
  {
    char letter;
    int count = 0;
  
    for (letter = 32; letter &lt; 127; letter++, count++)
      {
        if (count == 16)
          {
            cout &lt;&lt; endl;
            count = 0;
          }
        cout &lt;&lt; letter &lt;&lt; " ";
      }
  
    cout &lt;&lt; endl;
  
    return 0;
  
  }
  </code></pre>
  
  <p>Again, the above code runs fine and does what I want it to.  The difficulty lies in something I tried before this.  I attempted to do the same problem with a nested while loop, like so:</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  int main()
  {
    char letter = 32;
    int count;
  
    while (letter &lt; 127)
      {
        count = 0;
        while (count &lt; 16)
          {
            cout &lt;&lt; letter &lt;&lt; " ";
            letter++;
            count++;
          }
        cout &lt;&lt; endl;
      }
  
    cout &lt;&lt; endl;
  
    return 0;
  
  }
  </code></pre>
  
  <p>This while loop just runs infinitely and also spits out some garbage after the ASCII characters I want, and I can't figure out why.  What's even weirder is if I change the variable 'letter' in the code with while loops to an int instead of a char, it runs exactly the way I want it to and terminates when it should, just displaying the actual numbers instead of the ASCII values.  </p>
  
  <p>It's only when 'letter' is a char that I get an infinite loop.  I'm sure it's something really simple, and I might just be too tired to see it right now, but any help/hints would be much appreciated!  Even though I technically got the answer, it's driving me crazy that I don't know WHY the second answer fails so horribly.</p>
  
  <p>Thanks in advance.</p>