C fseek( )


This function is used to set the file pointer to the specified offset. It is used to write data into the file at the desired location.


Syntax:

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

 

The fseek() function used three constants such as:

SEEK_SET, SEEK_CUR AND SEEK_END.


Example:

#include <stdio.h>
#include <stdlib.h>

void main()
{
	FILE *fp;
	fp=fopen("TEST.txt","w+");
	fputs("Onlinetpoint for",fp);
	fseek(fp,20, SEEK_SET);
	fputs("C program Language",fp);
	fclose(fp);
}



OnlineTpoint is a website that is meant to offer basic knowledge, practice and learning materials. Though all the examples have been tested and verified, we cannot ensure the correctness or completeness of all the information on our website. All contents published on this website are subject to copyright and are owned by OnlineTpoint. By using this website, you agree that you have read and understood our Terms of Use, Cookie Policy and Privacy Policy.