C fseek() function

C fseek() function

C fseek() function

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:

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:

#include <stdio.h>

void main(){

FILE *fp;

fp = fopen(“myfile.txt”,“w+”);

fputs(“This is CloudsNClear”, fp);

fseek( fp, 7, SEEK_SET );

fputs(“Rohit Sharma”, fp);

fclose(fp);

}

myfile.txt

This is Rohit Sharma

Related Post:

Features of C Programming Language

Variables in C

Data Types in C

Keywords in C

C Operators

Comments in C

Escape Sequence in C

C Functions

Storage Classes in C

Dynamic memory allocation in C

Factorial Program in C

Leap year program in C

Fibonacci Series in C

Prime Number program in C

Palindrome program in C

Sum of digits program in C

Escape Sequence in C

ASCII value in C

Difference Between Type Casting and Type Conversion in C

Difference Between Variables and Constants

Matrix multiplication in C

C Program to generate Fibonacci Triangle

C Program to print “hello” without semicolon

C Program to swap two numbers without third variable

C Program to reverse number

Count the number of digits in C

Tokens in C

C Identifiers

C Strings

Compile time vs Runtime in C

C break statement

C goto statement

Type Casting in C

C String Functions

C Pointers

Dangling Pointers in C

void pointer in C

Pointer to Pointer in C

Recursion in C

Call by value and Call by reference in C

File Handling in C

C fprintf() and fscanf()

C fputc() and fgetc()

C fputs() and fgets()

Constant Pointers in C

3 thoughts on “C fseek() function

  1. Pingback: Compile time vs Runtime in C - CloudNClear

  2. Pingback: Type Casting in C - CloudNClear

  3. Pingback: C fputc() and fgetc() - CloudNClear

Comments are closed.