title: How to draw a histogram with ncurses?
body: <p>I have a code that reads from input, counts letters and draws a histogram as ASCII art. I would like to do the same but with ncurses. How to do it?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  int main(void) {
    int c, i, j;
    int chars[256];
    // a counter for every character in the ASCII set
    for (i = 0; i &lt; 256; ++i) {
      chars[i] = 0;
    }
    // check each input and increment the relative element
    while ((c = getchar()) != '0') {
      ++chars[c];
    }
    // print only those characters that were received
    for (i = 0; i &lt; 256; ++i) {
      // go through every element in chars
      if (chars[i] &gt; 0) {
        // print headers
        if (i == ' ')
          printf(" Space: ");
        else if (i == '\n')
          printf("    \\n: ");
        else if (i == '\t')
          printf("   tab: ");
        else
          printf("%6c: ", i);
        for (j = 0; j &lt; chars[i]; ++j)
          // print a # for every tally of each element; chars[i] is the tally
          putchar('#');
          // and we need to go through each from 0 to the final tally of that element
        printf("\n");
      }
    }
  }
  </code></pre>