Design and Develop a program to demonstrate fseek function.

AIM:

Design and Develop a program to demonstrate fseek function.

Program:

#include<stdio.h>
Void main(int argc,char * argv[])
{
FILE * IP;
If(argc!=2)
{
Printf(“one argument is needed \n”);
exit(-1);
}
Ip=fopen(argv[1],”r”);
If(ip==0)
{
Printf(“ERROR in opening file”);
exit(-1);
}
fseek(ip,0,SEEK_END);
Printf(“File size=% 1d \n”,ftell(ip));
}

Output:

Student@ubuntu:~$ cat > e1
Hello
^z
Student@ubuntu:~$gcc –o g1.out g1.c
Student@ubuntu:~$ ./g1.out e1
Student@ubuntu:~$file size = 6