#include "stdafx.h"
#include <stdlib.h>/*为了调用system("PAUSE");*/
#include <time.h>/*为了调用time;*/
#include <stdio.h>
#include <string.h>
#include <windows.h>
int main(int argc , char* argv[])
{
FILE *fp;
char ch, filename[100];
printf("Input the file name:");/*输入文件名字*/
gets_s(filename); /*VS2015使用的是新的C标准C11,所以用gets_s,其他编译器可以用gets*/
if((fp=fopen(filename,"r"))==NULL)
{
printf("Open file fail!\n");
return C_SYS_ERR;
}
ch =fgetc(fp); /*读文件第一个字符*/
while(ch!= EOF) /*读取内容是EOF时候结束循环*/
{
putchar(ch); /*将读到的内容打印在屏幕上*/
ch =fgetc(fp);/*继续读文件字符*/
}
fclose(fp);
system("PAUSE");
return C_SYS_OK;
}