home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / comms / bbs / quest.lha / questions.c next >
Encoding:
C/C++ Source or Header  |  1992-02-02  |  1.2 KB  |  60 lines

  1. /* new user q */
  2. /* 1 arg: %UNAME */
  3. /* karl eklund */
  4.  
  5. #include <stdio.h>
  6.  
  7. main(argc,char *argv[]) {
  8.     FILE *fp;
  9.     FILE *qfile;
  10.     FILE *afile;
  11.  
  12.     char filnamn[255] = "user:";
  13.     char question[400];
  14.     char answer[400];
  15.  
  16.     strcat(filnamn,argv[1]);
  17.     strcat(filnamn,"/q");
  18.  
  19.     fp = fopen(filnamn,"r");
  20.     if(fp) {
  21.         puts("You've already answered these questions.");
  22.         puts("Do you still want to continue? (y/N)");
  23.         gets(answer);
  24.         if(!(answer[0] == 'y' || answer[0] == 'Y')) {
  25.             fclose(fp);
  26.             exit(0);
  27.         }
  28.         puts("\n");
  29.     }
  30.  
  31.     qfile = fopen("dlgconfig:misc/newusers.questions","r");
  32.  
  33.     if(!qfile) {
  34.         puts("Please tell your sysop to create a \"dlgconfig:misc/newusers.questions\" file");
  35.         exit(0);
  36.     }
  37.  
  38.     afile = fopen("dlgconfig:misc/newusers.answers","a");
  39.  
  40.     fputs("\n\n-----------------------------------------------------------------------------\n",afile);
  41.     fputs(argv[1],afile);
  42.     fputs("\n",afile);
  43.  
  44.     while(fgets(question,sizeof(question),qfile)) {
  45.         if(question[0] != '*') {
  46.             puts("");
  47.             printf("%s",question);
  48.             gets(answer);
  49.             fputs(question,afile);
  50.             fputs(answer,afile);
  51.             fputc('\n',afile);
  52.         } else printf("%s",question);
  53.     }
  54.     fclose(qfile);
  55.     fclose(afile);
  56.     fp = fopen(filnamn,"w");
  57.     fputs("hubba",fp);
  58.     fclose(fp);
  59. }
  60.