📄 cd.cpp
字号:
#include<stdio.h>
#include<process.h>
long d_length(FILE*fp)
{
long curpos,length;
curpos=ftell(fp);/*求取文件指针的相对于文件开始的相对位置*/
printf("\n the begin of this file is %Ld\n",curpos);
fseek(fp,0L,SEEK_END);/*文件指针指向文件末尾*/
length=ftell(fp);
printf("\n the end of this file is %Ld\n",length);
fseek(fp,curpos,SEEK_SET);/*恢复文件指针的初始值*/
return(length);
}
void main()
{char name[100];
long d_len;
FILE*d_fp;
printf("Input a filename:");
scanf("%s",name);
if((d_fp=fopen(name,"r"))==NULL)
{printf("\n open file error\n");
exit(0);
}
d_len=d_length(d_fp);
printf("the length of %s is %Ld bytes\n",name,d_len);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -