Jump to content

User:Shuo Xiang/Post.c

From Wikipedia, the free encyclopedia
#include <stdio.h>

main()
{
 char input[3000];
 int n = 0;
 FILE *f;

 fgets(input, 2999, stdin);
 f = fopen("cs492a6.out", "a");
 fprintf(f,"\n%s\n", input);
 fclose(f);

 f = fopen("token", "r");
 fscanf(f, "%d", &n);
 fclose(f); 

 f = fopen("token", "w");
 fprintf(f, "%d", n+1);
 fclose(f);

 printf("Content-type: text/html\n\n");
 printf("<html>\n<body>\n");
 printf("<h1>Thank you!</h1>\n", input);
 
 printf("<p>You have the honor of being the <strong>%d</strong>th person to respond to my survey using the dropbox!</p>\n", n);
 printf("<p>Thank you for your participation. Your responses to the survey are much appreciated!</p>\n");
 printf("<p>The final essay should be posted on my user page no later than March 27. Stay tuned!!!</p>");
 printf("</body>\n</html>\n");
}