rewind()

Places the pointer at the beginning of the file FileDesc.

Synopsis

long rewind( file FileDesc );

Parameters

Parameter Description
FileDesc File

Return value

If successful, the function returns 0 or in the event of an error, -1.

Error

Invalid or missing arguments

Description

The file pointer is placed at the beginning of the file.

Example

main()
{
  file f;
  string dummy;
  f=fopen("C:/TMP/TEST.TXT", "r+"); // read and write
  while(feof(f)==0) //so long as it is not at the end
  {
    fgets(dummy, 20, f); //readsfrom the file in
    dummy
    DebugN(dummy);
  }
  rewind(f); //back to the beginning
  fputs("New 1. line", f); //writes to the beginning
}

Assignment

File function

Availability

CTRL