title: how can i save the output of putchar to a variable
body: <p>I am working on some code that filters text before it is sent further into a program (this code removes everything but all alphanumeric characters and and underscores), the code itself works perfectly except for the fact that I cannot find a way to store the output of of it for use in other parts of the program, If i had to guess, this probably involves saving the stdout from putchar into a variable, but i cannot find much info for doing so online, if someone could point me in the right direction for this I would really appreciate it, thanks!</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  #include &lt;ctype.h&gt;
  int main(void) {
      int i;
      char *p;
      char stg[] = "hello";
          for (p = &amp;stg[0]; *p != '\0'; p++) {
             if (isalnum(*p) || *p == '_') {
             putchar (*p);
             }
          }
          putchar ('\n');
      return 0;
  }
  </code></pre>