title: histogram nested loop not printing full graph
body: <p>I have been going through <a href="https://www.amazon.ca/Programming-Language-2nd-Brian-Kernighan/dp/0131103628" rel="nofollow noreferrer">The C programming language (2nd addition)</a> exercises to try and improve my coding skills. I am currently on exercises 1-13 which requires you to write a program that prints a histogram of the lengths of words in its input.</p>
  <p>Here is my code:</p>
  <pre><code>#include &lt;stdio.h&gt;
  
  #define INWORD 1
  #define OUTOFWORD 0
  
  main ()
  {
  int word_state;
  int word_count, word_length, c;
  int A_word_array[50];
  
  word_count = word_length = c = 0;
  word_state = OUTOFWORD;
  
  for (int i = 0; i &lt; 50; i++)
      A_word_array[i] = 0;
  
  
      while ((c = getchar()) != EOF)
      {
          if (c == '\t' || c == '\n' || c == ' ') 
          {
              if (word_state == INWORD)
              {
              word_state = OUTOFWORD;
              word_length = 0;
              }
          
          }
          else
          {
              if (word_state == OUTOFWORD)
              {
                 ++word_length;
                 ++word_count;
               A_word_array[word_count-1] = word_length;
               word_state = INWORD;
            
          
              }
          
              else
              {
                ++word_length;
                    A_word_array[word_count-1] = word_length;
            
              }
          }
  
  
      }
  
      for (int k = 0; k &lt; word_count; k++)
      {
  
          for (int m = 0; m &lt; A_word_array[k] ; m++)
          {
              printf(&quot;o&quot;);
          }
  
      printf(&quot;\n&quot;);
      
      }
  
  }
  </code></pre>
  <p>For some reason when I run this code in command prompt for VS it begins to print the histogram but then abruptly stops. For example, if I were to write &quot;This is a test code!&quot; press enter and CTRL+ C (to end file) I get:</p>
  <p>ooo^C</p>
  <p>Instead of:</p>
  <p>oooo</p>
  <p>oo</p>
  <p>o</p>
  <p>oooo</p>
  <p>ooooo
  ^C</p>
  <p>This issue seems to stem fro the second for loop. I am unsure if it is a small error or just some limitation I am not aware of with command prompt V22 but I am stumped. Any and all guidance is much appreciated.</p>