perl in c

Could anyone help me to solve this problem ?

I would like to use pure C to write a very simple cgi script.

OK. This script will get an input( integer ) from the user
on the net, after user entered an integer and pressed the submit button. That number will store in a text file called num.txt. So, the text file should not be overwrote, it should be able to store as many as it can.

Please tell me how to call that script from the html and do I have to change any thing in server conf file ?
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

jhurstConnect With a Mentor Commented:
#include <stdio.h>
#include <stdlib.h>
#include <stdring.h>

int main(void)
  FILE *numTxt=fopen("nu.m.txt","at"); /* the file will be appended to */
  char str[80];                                      /* just some work space */
  char *ptr;                                          /* will search soon */

  fgets(str,70.stdin);                            /* get the post parameters */

  ptr=strchr(str,'=');                              /* so we can get the first value */

  fprintf(numTxt,"%d\n",atoi(ptr+1));    /* the value is right after the =-sign */
  fclose(numTxt);                                /* we are done with it */
  printf("Content-Type: text/html\n\n"); /* send a reply */
  printf("<html><body>We Received the Number: %d<p>\n",atoi(ptr+1));
                                                          /* let him see what we did */
  printf("</body></html>\n");              /* finish the generated page *
  return(0);                                        /* we are done */

The html:
<form action=your-cgi-name-path method=post>
Ypur Number: <input type=text name=theNumber>
<input type=submit>

atoi converts string to integer
gives i as 1001
All Courses

From novice to tech pro — start learning today.