title: Returning string from C system() function
body: <p>I just learned C and fascinates with pointers. Recently I discovered C function <code>system()</code>. I am able to get return values from a program I executed via <code>system</code> ("<code>program.exe</code>"). Eg, <code>program.c</code>:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  
  int main(){
      printf("hello world\n");
  
      return 123;
  }
  </code></pre>
  
  <p>and this code calls <code>program.exe</code>, called <code>call.c</code></p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  
  int main(){
      int a;
      printf("calling program.exe:\n");
      a=system("program.exe");
      printf("program.exe returned %d at exit\n",a);
  
      return 0;
  }
  </code></pre>
  
  <p>When I execute <code>call.exe</code>, I get this</p>
  
  <pre><code>calling program.exe:
  hello world
  pm returned 123 at exit
  </code></pre>
  
  <p>I was like, wow! This return value and <code>system()</code> function thing is like a new way to interprocess communication for me. But my question is, can I get a string return from the <code>system()</code> function?</p>
  
  <p>Ii tried changing <code>program.c</code> "<code>int main()</code>" to "<code>char * main()</code>", and <code>return 123</code> to <code>return "bohemian rhapsody"</code> and change "<code>int a;</code>" to "<code>char *a;</code>", <code>printf</code> format <code>%d</code> to <code>%s</code> in <code>call.c</code>, but I only get funny characters when I execute call.exe. I wonder what's wrong?</p>