Cheap VPS & Xen Server


Residential Proxy Network - Hourly & Monthly Packages

C fseek()


The fseek() function is used to set the file pointer to the specified offset. It is used to write data into file at desired location.

Syntax:

  1. int fseek(FILE *stream, long int offset, int whence)

There are 3 constants used in the fseek() function for whence: SEEK_SET, SEEK_CUR and SEEK_END.

Example:

  1. #include <stdio.h>
  2. void main(){
  3.    FILE *fp;
  4.    fp = fopen(“myfile.txt”,“w+”);
  5.    fputs(“This is Kreationnext”, fp);
  6.    fseek( fp, 7, SEEK_SET );
  7.    fputs(“sonoo jaiswal”, fp);
  8.    fclose(fp);
  9. }

myfile.txt

This is sonoo jaiswal

Comments

comments