⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 genindex.c

📁 BOSS窗口开发 C 语言程序库
💻 C
字号:
/*
** GENINDEX - Create index from text file.
** 
** Support Program for The Window BOSS
**
** Copyright (c) 1984,1985,1986 - Philip A. Mongelluzzo
** All rights reserved.
**
**  If you attempt to recompile this program you may have to 
**  adjust the logic to account for the way the various compilers 
**  treat <CR><LF> sequences.  This usually amounts to nothing 
**  more than chaning the "rb" to "r" in the fopen statement.  
*/

#include <stdio.h>                      /* Standard stuff */
#if AZTEC
#define RD "r"
#else
#define RD "rb"
#endif


FILE *fopen();                          /* keep the compilers happy */
long ftell();

main(argc,argv)
int argc;
char *argv[];
{
FILE *fp;
FILE *fo;
char buf[257];
static char fname[132];
unsigned i;
long pos;
char *p;

  if(argc < 2) {                        /* check command line */
    printf("Usage: genindex <filename.ext>");
    exit(1);
  }

  p = argv[1];                          /* parse input filename */
  i = 0;
  while(*p) {
    fname[i++] = *p++;
    if(*p == ' ' || *p == '.') break;
  }
  strcat(fname, ".ndx");                /* create output filename */

  fp = fopen(argv[1], RD);             /* open input */
  if(!fp) {
    printf("Open failed: %s", argv[1]);
    exit(1);
  }
  printf("Creating: %s\n", fname);      /* say whats going on */
  fo = fopen(fname, "w");               /* open output */

  while(fgets(&buf[0],256,fp)) {        /* read lines till eof */
    if(buf[0] == '%') {                 /* look for subject heading key */
      fputs(buf, fo);                   /* write to index file */
      fputs(buf, stdout);               /* display on console */
      pos = ftell(fp);                  /* get file position */
      printf("%ld\n", pos);             /* display on console */
      fprintf(fo, "%ld\n", pos);        /* write in output file */
    }
  }
  fclose(fp);                           /* close files */
  fclose(fo);
}

/* End */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -