From 754bbf7a25a8dda49b5d08ef0d0443bbf5af0e36 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 7 Apr 2024 13:41:34 -0500 Subject: new repository --- devdocs/c/io%2Frewind.html | 51 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 devdocs/c/io%2Frewind.html (limited to 'devdocs/c/io%2Frewind.html') diff --git a/devdocs/c/io%2Frewind.html b/devdocs/c/io%2Frewind.html new file mode 100644 index 00000000..103aceef --- /dev/null +++ b/devdocs/c/io%2Frewind.html @@ -0,0 +1,51 @@ +

rewind

Defined in header <stdio.h>
void rewind( FILE *stream );
+

Moves the file position indicator to the beginning of the given file stream.

+

The function is equivalent to fseek(stream, 0, SEEK_SET);, except that end-of-file and error indicators are cleared.

+

The function drops any effects from previous calls to ungetc.

+

Parameters

+ +
stream - file stream to modify

Return value

(none)

+

Example

+

This example shows how to read a file twice

+
#include <stdio.h>
+ 
+char str[20];
+ 
+int main(void)
+{
+    FILE *f;
+    char ch;
+ 
+    f = fopen("file.txt", "w");
+    for (ch = '0'; ch <= '9'; ch++) {
+        fputc(ch, f);
+    }
+    fclose(f);
+ 
+    f = fopen("file.txt", "r");
+    fread(str, 1, 10, f);
+    puts(str);
+ 
+    rewind(f);
+    fread(str, 1, 10, f);
+    puts(str);
+    fclose(f);
+ 
+    return 0;
+}

Output:

+
0123456789
+0123456789

References

See also

+ +
moves the file position indicator to a specific location in a file
(function)
C++ documentation for rewind
+

+ © cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
+ https://en.cppreference.com/w/c/io/rewind +

+
-- cgit v1.2.3