home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / SIMTEL / CPMUG / CPMUG053.ARK / SAVEADV.C < prev    next >
C/C++ Source or Header  |  1984-04-29  |  741b  |  38 lines

  1.  
  2.  /* SAVEADV.C  no mods for V 1.43 
  3.  */
  4. #include "advent.h"
  5.  
  6. main()
  7. {
  8.     /*
  9.         save adventure game
  10.     */
  11.     char *sptr;
  12.     int savefd;
  13.     char username[13];
  14.  
  15.     printf("What do you want to call the saved game? ");
  16.     scanf("%s",username);
  17.     strcat(username,".adv");
  18.     if ((savefd=fcreat(username,dbuff)) == -1) {
  19.         printf("sorry, I can't create the file...\n");
  20.         exit();
  21.     }
  22.     for (sptr=&turns; sptr<&lastglob; sptr++) {
  23.         if (putc(*sptr,dbuff) == -1) {
  24.             printf("write error on save file...\n");
  25.             exit();
  26.         }
  27.     }
  28.     if (fflush(dbuff) == -1) {
  29.         printf("flush error on save file...\n");
  30.         exit();
  31.     }
  32.     if (close(savefd) == -1) {
  33.         printf("can't close save file...\n");
  34.         exit();
  35.     }
  36.     printf("OK -- \"C\" you later...\n");
  37. }
  38.