title: How to loop through all ASCII characters?
body: <p>I am attempting to write a program which loops through all ASCII characters, selects those which are letters, appends them to a string and then outputs this string. I have written the following code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include "ctype.h"
  
  using namespace std;
  
  int main()
  {
     string str;
  
     for (char k = 0; k &lt;= 255; k++) 
         if (isalpha(k) != 0) {
            str += k;
     }
  
     cout &lt;&lt; str &lt;&lt; '\n';
  }
  </code></pre>
  
  <p>However, when I run this code I get a 'bad_alloc' error, which to my understanding means I ran out of memory. Thus, I must have done something terribly wrong in my code. I am very new to C++ in general, could someone point out my (possibly many) mistakes?</p>