打开文件出错
#include<stdio.h>#include<stdlib.h>
#include<conio.h>
int main()
{
FILE *fp;
char words[81];
long count,last;
char ch;
puts("Enter the name of file to be processed:");
gets(words);
//读取文件
if((fp=fopen(words,"rb"))==NULL)//只读和二进制模式
//if((fp=fopen("d:\vital","rb"))==NULL)
{
printf("I couldn't open the file \"%s\"\n",words);
exit(1);
}
fseek(fp,0L,SEEK_END);//定位文件末尾
last=ftell(fp);
for(count=1L;count<=last;count++)
{
fseek(fp,-count,SEEK_END);//回退
ch=getc(fp);
}
putchar('\n');
fclose(fp);
getch();
return 0;
}