fseek() in C programming
File Handling : fseek() in C programmingFile Handling in C programming is a prime feature which helps to operate larger files without any obstruction and also helps us to perform various functions such as read,write,etc. any file which is stored on our local system using C Language. File handling helps to eliminate the problem of handling and displaying large amount of data.In this section, we will learn the fseek() function of file handling in C programming.
fseek() function in C programming:
Syntax of fseek() :
int fseek(FILE *pointer, long int offset, int position);
There are various parts of this syntax which are mentioned below:
- Pointer- It is used to point to the File object that helps to find the stream in which data is to be written.
- Offset- It represents the number of bytes to the offset from the specified position.
- Position- It specifies the position according to which the file pointer needs to be moved and from where the offset is to be added.There are 3 values which are
- SEEK_END – It represents the end of file.
- SEEK_SET – It represents the start of file.
- SEEK_CUR – It represents the current position of the file pointer.
The above code sets the pointer of the file 7 places ahead from the start of the file using the SEEK_SET argument.
Get over 200+ course One Subscription
Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others