title: How To Use C++ CGI Script?
body: <p>I am currently enrolled in a web applications class at my college and we are learning about cgi scripts. I am having a hard time learning how to implement my CGI script. When I click on my link a window pops up asking me to download my helloworld.cgi file instead of just redirecting. </p>
  
  <p><strong>HTML:</strong></p>
  
  <pre><code>&lt;html&gt;
      &lt;body&gt;
          &lt;a href="/user/local/apache2/cgi-bin/helloworld.cgi"&gt;click me&lt;/a&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>C++:</strong></p>
  
  <pre><code>#include &lt;iostream&gt;
  
  using namespace std;
  
  int main(){
      cout &lt;&lt; "Content-type: text/html" &lt;&lt; endl;
      cout &lt;&lt; "&lt;html&gt;" &lt;&lt; endl;
      cout &lt;&lt; "   &lt;body&gt;" &lt;&lt; endl;
      cout &lt;&lt; "       Hello World!" &lt;&lt; endl;
      cout &lt;&lt; "   &lt;/body&gt;" &lt;&lt; endl;
      cout &lt;&lt; "&lt;/html&gt;" &lt;&lt; endl;
  
      return 0;
      }
  </code></pre>
  
  <p>The CGI script is stored at <code>/user/local/apache2/cgi-bin/helloworld.cgi</code></p>