C file:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char* argv[])
{
  FILE *ptr;
  char m[200];
  char *data = malloc(200);
  data=getenv("QUERY_STRING");
  sscanf(data,"%s", m);
  printf("%s", m);
  ptr=fopen("c:/test.txt", "w");
  fprintf(ptr, "%s", m);
  fclose(ptr);
  return 0;
}
//gcc -g print.c -o print.exe
HTML file:
<html>
  <body>
    <h2>CGI Server</h2>
    <p>
      <form action="http://localhost/cgi-bin/print.exe">
    <div><label>value: <input name="m" size="10"></label></div>
    <div><input type="submit" value="Run"></div>
      </form>
    </p>
  </body>
</html>
If the input into the webpage form is c:/data.txt then the result is: c%3A%2Fdata.txt
What happened? Why are the / and the : damaged in the output? it seems the problem is with QUERY_STRING because getenv("PATH") doesn't present this problem.