Knowledge Walls
Venkatesan
Hyderabad, Andhra Pradesh, India
Passcode:
Introduction [cont'd]
Input Output Functions [cont'd]
Structures and Unions [cont'd]
# Preprocessor [cont'd]
fseek(), ftell() and rewind() in Files of Programming in C
75270 Views
fseek(), ftell() and rewind() 
fseek() - It is used to moves the reading control to different positions using fseek function.
ftell() - It tells the byte location of current position in file pointer.
rewind() - It moves the control to beginning of a file.
Program
	#include
	void main(){
	   FILE *fp;
	   int i;
	   clrscr();
	   fp = fopen("CHAR.txt","r");
	   for (i=1;i<=10;i++){
	       printf("%c : %d\n",getc(fp),ftell(fp));
	       fseek(fp,ftell(fp),0);
	       if (i == 5)
	       rewind(fp);
	   }
	   fclose(fp);
	}
Output 
W : 0
e : 1
l : 2
c : 3
o : 4
W : 0
e : 1
l : 2
c : 3
o : 4
Next Topics
Next lessons of current book.
# Preprocessor of Programming in C
# Preprocessor of Programming in C
Previous Topics
Previous lessons of current book.
Best Lessons of "Programming in C"
Top lessons which are viewed more times.
Structures and Unions of Programming in C
Input Output Functions of Programming in C
Structures and Unions of Programming in C
  Copyright © 2014 Knowledge walls, All rights reserved
KnowledgeWalls
keep your tutorials and learnings with KnowledgeWalls. Don't lose your learnings hereafter. Save and revise it whenever required.
Click here for more details