C examples for stdio.h:rewind
function
<cstdio> <stdio.h>
Set position of stream to the beginning
void rewind ( FILE * stream );
Parameter | Description |
---|---|
stream | FILE object |
none
#include <stdio.h> int main ()//from w ww . j a v a2 s . c o m { int n; FILE * pFile; char buffer [27]; pFile = fopen ("main.cpp","w+"); for ( n='A' ; n<='Z' ; n++) fputc ( n, pFile); rewind (pFile); fread (buffer,1,26,pFile); fclose (pFile); buffer[26]='\0'; puts (buffer); return 0; }