showfile.c

来自「The art and science of c_source code!」· C语言 代码 · 共 32 行

C
32
字号
/* * File: showfile.c * ---------------- * This program reads a file name from the user and displays * the contents of that file on the console. */#include <stdio.h>#include "genlib.h"#include "simpio.h"/* Main program */main(){    string filename;    FILE *infile;    char ch;    printf("This program displays an input file.\n");    while (TRUE) {        printf("Input file name: ");        filename = GetLine();        infile = fopen(filename, "r");        if (infile != NULL) break;        printf("Can't open the file %s.  Try again.\n", filename);    }    while ((ch = getc(infile)) != EOF) {        putc(ch, stdout);    }}

⌨️ 快捷键说明

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