C中的ftell()
用C语言ftell()返回相对于文件开头的指定流的当前文件位置。在文件末尾移动文件指针后,此函数用于获取文件的总大小。它以long类型返回当前位置,并且文件可以包含32767字节以上的数据。
这是ftell()C语言的语法,
long int ftell(FILE *stream)
这是在中使用的参数ftell(),
stream-这是指向标识流的FILE对象的指针。
这是ftell()C语言的示例。
假设我们有一个包含以下内容的文件“one.txt”。
This is demo text! This is demo text! This is demo text!
现在,让我们来看一个例子。
示例
#include <stdio.h>
#include<conio.h>
void main () {
FILE *f;
int len;
f = fopen("one.txt", "r");
if(f == NULL) {
perror(“Error opening file”);
return(-1);
}
fseek(f, 0, SEEK_END);
len = ftell(f);
fclose(f);
printf("Size of file: %d bytes", len);
getch();
}输出结果
Size of file: 78 bytes
热门推荐
1 狗狗下楼训练
3 狗狗训练头盔
6 狗狗训练机构
7 训练狗狗步骤
9 狗狗能训练
10 狗狗基本动作训练方法
11 怎么训练狗狗叼饭盆
12 狗狗一岁了还能训练吗
13 训练狗狗的
14 宁波狗狗训练
15 训练狗狗拉屎
16 教狗狗训练
17 狗狗要怎么训练上厕所
18 狗狗靠的训练