GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::rewind(3) C++ Standard Libary std::rewind(3)

std::rewind - std::rewind


Defined in header <cstdio>
void rewind( std::FILE* stream );


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


The function is equivalent to std::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.


stream - file stream to modify


(none)

// Run this code


#include <cstdio>


int main()
{
std::FILE *f;
char ch;
char str[20];


f = std::fopen("file.txt", "w");
for (ch = '0'; ch <= '9'; ch++) {
std::fputc(ch, f);
}
std::fclose(f);


std::FILE* f2 = std::fopen("file.txt", "r");
unsigned int size = std::fread(str, 1, 10, f2);
std::puts(str);
std::printf("\n%u\n",size);


std::rewind(f2);
unsigned int size2 = std::fread(str, 1, 10, f2);
std::puts(str);
std::printf("\n%u",size2);
std::fclose(f2);
}


fseek moves the file position indicator to a specific location in a file
(function)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.