fsetpos - C stdio.h

C examples for stdio.h:fsetpos

Type

function

From


<cstdio>
<stdio.h>

Description

Set position indicator of stream. Restores the current position in the stream to pos.

Prototype

int fsetpos ( FILE * stream, const fpos_t * pos );

Parameters

ParameterDescription
stream FILE object
position Pointer to a fpos_t object containing a position previously obtained with fgetpos.

Return Value

On success, it returns zero.

On failure, a non-zero value is returned and errno is set to a system-specific positive value.

Demo Code


#include <stdio.h>

int main ()//from   w w w.  j av a  2  s.  c o m
{
  FILE * pFile;
  fpos_t position;

  pFile = fopen ("main.cpp","w");
  fgetpos (pFile, &position);
  fputs ("That is a test",pFile);

  fsetpos (pFile, &position);

  fputs ("This is a new test",pFile);
  fclose (pFile);
  return 0;
}

Related Tutorials