Agrego un posdata, al maestro de la pregunta, si estás trabajando en C o C# y queres mantenerte (vás a tener problema con la portabilidad), lo que debes indicar es una salida simplemente y ya tenes un CGI en C, practiquemos:
Código:
#include <stdio.h>
int main(int argc, char *argv[]) {
printf("Content-Type: text/html\n\n");
printf("<h1>%s</h1>", "hola Carola");
return 0;
}
Un ejemplo más funcional:
Código:
#include <sys/time.h>
#include <stdio.h>
#include <stdlib.h>
#define MICRO_IN_SEC 1000000.00
double microtime(void);
int main(int argc, char *argv[]) {
char string[12] = "Hola carola\0";
time_t start, end;
start=microtime();
printf("Content-Type: text/html\n\n");
printf("<h1>%s</h1>", "hola Carola");
FILE *fp;
fp=fopen("./sitio.c","r");
char content[500];
if (fp != NULL){
char tmp;
while (!feof(fp)){
tmp=fgetc(fp);
strcat(content, &tmp);
}
fclose(fp);
} else {
strcat(content, "<span style=\"color:red\">Error no puedo abrir el archivo</span>");
}
free(fp);
printf("Este es el código fuente de este sitio: <pre>%s</pre>", content);
end=microtime();
printf("Esta página tardo en ejecutarse %f, %s", difftime(end, start), string);
return 0;
}
double microtime(void) {
return((double)(clock() / CLOCKS_PER_SEC));
}
Todavía no va a funcionar al menos en Apache cuando cuando lo compiles renombralo a cgi y listo, despúes buscas cuando sepas más como agregar tipos mimes.
Saludos