home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_100 / 155_01 / treeinit.c < prev    next >
C/C++ Source or Header  |  1990-10-09  |  737b  |  35 lines

  1. #include <stdio.h>
  2. #include "btree.h"
  3.  
  4.  
  5. /* This program initializes a file as a valid key file.  This
  6.  *  program must be used to set-up key files properly.
  7.  */
  8.  
  9.  
  10. main()
  11. {
  12.     extern char instr[];
  13.  
  14.     FILE *fopen(), *fd;
  15.     char filename[20];
  16.     struct keyinfo fileinfo;
  17.  
  18.     printf("\n\nName of key file to initialize: ");
  19.     gets(filename);
  20.     printf("\n\nLength of Key: ");
  21.     gets(instr);
  22.     fileinfo.keylength = atoi(instr);
  23.     if ((fd = fopen(filename, "w")) != NULL) {
  24.         fprintf(fd,"%c%2d%5ld%5ld%5ld%c",
  25.                '~',fileinfo.keylength,1L,0L,0L,'~');
  26.         fclose(fd);
  27.     }
  28.     else {
  29.         BELL
  30.         printf("\nCan't open file %s\n", filename);
  31.     }
  32.     exit(0);
  33. }
  34.  
  35.