C语言 :编写一个函数ShowTxt,把任一个给定文件名的字符文件的内容显示在计算机屏幕上。请高手指教,谢谢
1个回答
展开全部
#include <stdio.h>
#include <string.h>
void ShowTxt(char* filename)
{
FILE *fp;
if (filename == NULL)
{
printf("Usage: ShowTxt + file name");
return;
}
fp = fopen(filename, "r");
if (fp == NULL)
{
printf("File doesn't exit.");
return;
}
while (!feof(fp))
printf("%c", fgetc(fp));
getchar();
}
#include <string.h>
void ShowTxt(char* filename)
{
FILE *fp;
if (filename == NULL)
{
printf("Usage: ShowTxt + file name");
return;
}
fp = fopen(filename, "r");
if (fp == NULL)
{
printf("File doesn't exit.");
return;
}
while (!feof(fp))
printf("%c", fgetc(fp));
getchar();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询