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
-
UpdatedOct 23, 2014
-
Views2,365
You May Like
Write a Shell script to find factorial of a given integer.
Write in C the following Unix commands using system calls A). cat B). ls C). mv
Write a Shell script that displays list of all the files in the current directory to which the user has read, Write and execute permissions.
Write a Shell script that accepts a filename, starting and ending line numbers as arguments and displays all the lines between the given line numbers.
Write a C program to emulate the Unix ls-l command.
Write a Shell script to list all of the directory files in a directory.