title: C Programming - Writing text file that compiles itself
body: <p>I'm trying to write a file to disk that gets then recompiled automatically. Unfortunately, sth does not seem to work and I'm getting an error message I don't yet understand (I'm a C Beginner :-). If I compile the produced hello.c manually, it all works?!</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
      int main()
      {
          FILE *myFile;
          myFile = fopen("hello.c", "w");
          char * text = 
          "#include &lt;stdio.h&gt;\n"
          "int main()\n{\n"
          "printf(\"Hello World!\\n\");\n"
          "return 0;\n}";
          system("cc hello.c -o hello");
          fwrite(text, 1, strlen(text), myFile);  
          fclose(myFile);
          return 0;
      }
  </code></pre>
  
  <p>This is the error I get:</p>
  
  <p>/usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../../lib/crt1.o: In function <code>_start':
  (.text+0x20): undefined reference to</code>main'
  collect2: ld returned 1 exit status</p>