Description

The C library function void rewind(FILE *stream) sets the file position to the beginning of the file of the given stream.

Declaration

Following is the declaration for rewind() function.

void rewind(FILE *stream)

Parameters

  • stream − This is the pointer to a FILE object that identifies the stream.

Return Value

This function does not return any value.

Example

The following example shows the usage of rewind() function.

#include <stdio.h>

int main()
{
char str[] = "This is tutorialspoint.com";
FILE *fp;
int ch; /* First let's write some content in the file */
fp = fopen( "file.txt" , "w" );
fwrite(str , 1 , sizeof(str) , fp );
fclose(fp); fp = fopen( "file.txt" , "r" );
while(1)
{
ch = fgetc(fp);
if( feof(fp) )
{
break ;
}
printf("%c", ch);
}   //set the file position to the beginning, if it doesn't have this function, fp will point NULL ,because above while(1) and break when feof(fp) is true.
rewind(fp);
printf("\n");
while(1)
{
ch = fgetc(fp);
if( feof(fp) )
{
break ;
}
printf("%c", ch); }
fclose(fp); return(0);
}

Let us assume we have a text file file.txt that have the following content −

This is tutorialspoint.com

Now let us compile and run the above program to produce the following result −

This is tutorialspoint.com
This is tutorialspoint.com

C library function - rewind()的更多相关文章

  1. C library function - freopen()

    Description The C library function FILE *freopen(const char *filename, const char *mode, FILE *strea ...

  2. C library function - tmpfile()

    Description The C library function FILE *tmpfile(void) creates a temporary file in binary update mod ...

  3. Macro definition of snprintf conflicts with Standard Library function declaration

    Macro definition of snprintf conflicts with Standard Library function declaration 即将此处的宏定义注释掉,因为在VS2 ...

  4. [Swift]数学库函数math.h | math.h -- mathematical library function

    常用数学函数 1. 三角函数 double sin (double);//正弦 double cos (double);//余弦 double tan (double);//正切 2 .反三角函数 d ...

  5. python bug the C library strftime function.

    import timedef date2mktime(date, format_='%Y-%m-%d'): return int(time.mktime(time.strptime(date, for ...

  6. [工作积累] Android dynamic library & JNI_OnLoad

    Bionic libc doesn't load dependencies for current .so file (diff from Windows or Linux) so a explici ...

  7. c++学习书籍推荐《Beyond the C++ Standard Library》下载

    百度云及其他网盘下载地址:点我 作者简介 Björn Karlsson works as a Senior Software Engineer at ReadSoft, where he spends ...

  8. 【夯实PHP基础】PHP标准库 SPL

    PHP SPL笔记 这几天,我在学习PHP语言中的SPL. 这个东西应该属于PHP中的高级内容,看上去很复杂,但是非常有用,所以我做了长篇笔记.不然记不住,以后要用的时候,还是要从头学起. 由于这是供 ...

  9. flex-mp3

    Mp3Player.as package ddw.adobe { import flash.events.Event; import flash.events.IOErrorEvent; import ...

随机推荐

  1. php-fpm配置文件的优化

    php-fpm中比较重要的两项参数是:request_terminate_timeoutpm.max_children request_terminate_timeout该值决定了php-fpm进程的 ...

  2. JavaScript方法的调用

    1.假如是有名字的函数 调用是用名字调用,并且会把返回值赋值给接受它的参数 代码: function f() { alert("我是f"); return '我是返回值'; } f ...

  3. 【转】Unity中的协同程序-使用Promise进行封装(三)

    原文:http://gad.qq.com/program/translateview/7170967 译者:崔国军(飞扬971)    审校:王磊(未来的未来) 在这个系列的最后一部分文章,我们要通过 ...

  4. xampp使用phpunit

    1.将xampp/php的pear文件夹里面的phpunit文件夹复制到htdocs目录下 2.复制xampp/php的phpunit.bat到需要测试的目录 3.使用cmd命令切换至phpunit. ...

  5. nodejs 初入

    nodejs 模块路径 1.内置模块 如果传递给require函数的是NodeJS内置模块名称,不做路径解析,直接返回内部模块的导出对象,例:require('http'). 2. nodejs  支 ...

  6. Python基础二. 数据结构、控制流、运算符、真值测试

    一.概述 数据结构上广义上有两种,单一类型和集合类型 单一类型,表示一种对象 集合类型,表示包含多种对象 Python 中的内建的数据类型有str.list.tuple.dict.set.number ...

  7. 打开VS调试不进入开发的网站直接跳转到主页

    重启了熟悉有卸载IE11的,搞了好几个小时 最后把电脑管家里的锁定主页打开就好了! 很久之后  我再锁上  也没有这问题了

  8. (地址)propedit安装说明的地址

    proedit http://propedit.sourceforge.jp/eclipse/updates/

  9. SpringMVC源码剖析(二)- DispatcherServlet的前世今生

    上一篇文章<SpringMVC源码剖析(一)- 从抽象和接口说起>中,我介绍了一次典型的SpringMVC请求处理过程中,相继粉墨登场的各种核心类和接口.我刻意忽略了源码中的处理细节,只列 ...

  10. 反编译ILSpy 无法显式调用运算符或访问器 错误处理方法 转

    反汇编一个dll类库,导出的项目会报出很多bug,其中主要的就是“无法显式调用运算符或访问器”这个错误,看了一下,发现问题是在调用属性的时候,都 变成了方法,例如:pivotPoint.set_X(0 ...