rewind - C stdio.h

C examples for stdio.h:rewind

Type

function

From


<cstdio>
<stdio.h>

Description

Set position of stream to the beginning

Prototype

void rewind ( FILE * stream );

Parameters

ParameterDescription
stream FILE object

Return Value

none

Demo Code


#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;
}

Related Tutorials