关于用C语音打开文件的函数-FILE * fopen(const char * path,const char * mode);
http://baike.baidu.com/view/656681.htm百度的解释
也许还会以后会有些自己的见解会写下去 ,但现在就这样了
程序代码://file_eof.c --打开一个文件并显示其内容
#include<stdio.h>
#include<stdlib.h> //为了使用exit( )
int main()
{
int ch;
FILE * fp;
char fname[50]; //用于存放文件名
printf("Enter the name of the file: ");
scanf("%s",fname);
fp=fopen(fname,"r"); //打开文件以供读取
if(fp==NULL) // 尝试打开文件失败
{
printf("Failed to open file .Bye\n");
exit(1); //终止程序
}
//getc(fp) 从打开的文件中获取一个字符
while((ch=getc(fp))!=EOF)
putchar(ch);
fclose(fp); //关闭文件
return 0;
}