c语言ftell函数

C中的ftell()函数 (ftell() function in C)

Prototype:

原型:

    long int ftell(FILE *filename);

Parameters:

参数:

    FILE *filename

Return type: long int

返回类型: long int

Use of function:

使用功能:

The ftell() function returns the current value of the file indicator pointer for the specified stream. In case of binary stream it returns the position in terms of bytes from the beginning. The prototype of the function ftell() is:

ftell()函数返回指定流的文件指示器指针的当前值。 如果是二进制流,它将从头开始以字节为单位返回位置。 函数ftell()的原型为:

    long int ftell(FILE *filename);

When an error is occurred, it returns -1.

发生错误时,它返回-1。

C中的ftell()示例 (ftell() example in C)

#include <stdio.h>
#include <stdlib.h>
int main(){//Initialize the file pointer
FILE *f;
//Take a array of characters
char ch[100];
//Create the file for write operation
f=fopen("includehelp.txt","w");
printf("Enter five strings\n");
for(int i=0;i<4;i++){//take the strings from the users
scanf("%[^\n]",&ch);
//write back to the file
fputs(ch,f);
//every time take a new line for the new entry string
//except for last entry.Otherwise print the last line twice
fputs("\n",f);
//clear the stdin stream buffer
fflush(stdin);
}
//take the strings from the users
scanf("%[^\n]",&ch);
fputs(ch,f);
//close the file after write operation is over
fclose(f);
//open a file
f=fopen("includehelp.txt","r");
printf("\n...............print the strings..............\n");
while(!feof(f)){//takes the first 100 character in the character array
fgets(ch,100,f);
//and print the strings
printf("%s",ch);
}
rewind(f);
printf("\n...............print the position after print a strings ..............\n");
fgets(ch,100,f);
printf("%s",ch);
//print the current location
printf("the file indicator position is - %d\n",ftell(f));
//close the file
fclose(f);
return 0;
}

Output

输出量

翻译自: https://www.includehelp.com/c-programs/ftell-function-in-c-language-with-example.aspx

c语言ftell函数

c语言ftell函数_使用示例的C语言中的ftell()函数相关推荐

  1. c语言feof函数_使用示例的C语言中的feof()函数

    c语言feof函数 C语言中的feof()函数 (feof() function in C) Prototype: 原型: int feof(FILE* filename); Parameters: ...

  2. c++freopen函数_使用示例的C语言中的freopen()函数

    c++freopen函数 C语言中的freopen()函数 (freopen() function in C) Prototype: 原型: FILE* freopen(const char *str ...

  3. fclose函数_使用示例的C语言中的fclose()函数

    fclose函数 C中的fclose()函数 (fclose() function in C) Prototype: 原型: int fclose(FILE *filename); Parameter ...

  4. fopen函数的用法示例_使用示例的C语言中的fopen()函数

    fopen函数的用法示例 C语言中的fopen()函数 (fopen() function in C) Prototype: 原型: FILE *fopen(const char* filename, ...

  5. c语言里面gets(a)是什么意思,C语言中的gets()函数

    在c语言中读取字符串有多种方法,比如scanf() 配合%s使用,但是这种方法只能获取一个单词,即遇到空格等空字符就会返回.如果要读取一行字符串, 比如:I love MIT 这种情况,scanf() ...

  6. c语言使用free释放指针报错,C语言中的free函数用法执行机制分析

    free函数是C语言或者C++程序语言的常用函数,那么free函数有什么用途呢?free函数又怎么用呢?C语言中的free函数用法执行机制分析,一起来看看free内部的机制以及和delete的对比分析 ...

  7. C语言sleep函数linux,带你了解C语言中的Sleep函数(附代码)_后端开发

    三分钟了解C语言中自定义的标识符及规则_后端开发 C语言中的标识符有:关键字.预定义标识符.用户标识符.C语言中自定义标识符也有很多规则,下面我们一起来看看吧. Sleep函数: 功 能: 执行挂起一 ...

  8. main c语言中变量的定义,C语言中在main函数中定义的变量是全局变量么_后端开发...

    PHP 和 JavaSript 区别_后端开发 PHP是一种创建动态交互性站点的强有力的服务器端脚本语言,主要用于Web开发领域,而JavaSript是一种具有函数优先的轻量级,解释型或即时编译型的高 ...

  9. c语言自动生成系统时间函数,使用C语言中的time函数获取系统时间

    使用C语言中的time函数获取系统时间 可以通过time()函数来获得计算机系统当前的日历时间(Calendar Time),处理日期时间的函数都是以本函数的返回值为基础进行运算.其原型为: time ...

  10. c语言中的printf函数_C语言中的printf()函数与示例

    c语言中的printf函数 C语言中的printf()函数 (printf() function in C) The printf() function is defined in the <s ...

最新文章

  1. js中输出变量的类型和输出对象的的属性/方法/成员函数
  2. 从零写一个编译器(十二):代码生成之生成逻辑
  3. android rtsp协议转http协议_网络协议HTTP 协议(一)
  4. vim cscope taglist 使用
  5. mysql用binlog恢复数据_利用mysql的binlog恢复数据
  6. 【OpenCV 例程200篇】32. 图像的扭变(错切)
  7. 【操作系统】竞争条件与临界区
  8. EditText,TextView显示图片,超链接,颜色等
  9. 基于MATLAB的DS证据融合代码
  10. QT中使用ActiveX
  11. 参考线--深入了解字体
  12. 伪造邮件***,看我如何给网易邮箱APP发送垃圾邮件【二】
  13. 亚马逊——不一样的电商公司
  14. JAVA基础入门教程——Java介绍
  15. 蓝桥杯嵌入式设计与开发历届客观题答案
  16. slice扩容机制分析
  17. 旅行商问题的蚁群算法
  18. Crayon:新研究指出让IT决策者夜不能寐的原因
  19. 失去英国电信的华为是否会失去整个欧洲?
  20. 【Kaggle】纽约市出租车费预测(经典)

热门文章

  1. unity mysql 中文乱码_解决Unity3D中文乱码问题
  2. 编程小白C语言例题4
  3. TFTP软件测试自学,tftp 安装方法
  4. Centos 安装配置 Dynamips
  5. 64位电脑c语言程序下载,vc2010 x64位
  6. Node.js详细安装教程
  7. vue.js下载安装教程
  8. user-agent 批量汇总+随机返回一个
  9. pdflib使用:pdf的分割与合并
  10. 《高质量C/C++编程》读书笔记