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

📄 list.c

📁 c版本的
💻 C
字号:
/* *************************************************************** */
/* This program will read in any text file and list it on the      */
/* monitor with line numbers and with page numbers.                */
/* *************************************************************** */

#include "stdio.h"                     /* standard I/O header file */
#include "io.h"                        /* file I/O prototypes      */

void open_file(int no,char *name);
void open_print_file(void);
void print_a_line(void);
void top_of_page(void);

#define MAXCHARS 255                     /* maximum size of a line */
FILE *file_point;                    /* pointer to file to be read */
FILE *print_file_point;                      /* pointer to pronter */
char oneline[256];                     /* input string buffer area */

main(number,name)
int number;                 /* number of arguments on command line */
char *name[];               /* arguments on the command line       */
{
char *c;                       /* variable to indicate end of file */
char *point;

   point = name[1];
   open_file(number,point);     /* open the file to read and print */
   open_print_file();

   do {
      c = fgets(oneline,MAXCHARS,file_point);     /* read one line */
      if (c != NULL)
         print_a_line();                         /* print the line */
   } while (c != NULL);                      /* continue until EOF */

   top_of_page();                     /* move paper to top of page */
   fclose(file_point);                           /* close read file */
   fclose(print_file_point);                  /* close printer file */
}

⌨️ 快捷键说明

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