fseek doesn't work or work?

Dear all,
i wrote a function that list my file that it's binary and write it with fwrite from my struct:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
void ReadFile::printList(){
	clearerr(bookFilePtr);
	fseek(bookFilePtr,0L,SEEK_SET); // set to begin of file
	int counter = 1;
	cout << "***************************************************" << endl;
	struct book tmp ;
	while (!feof(bookFilePtr)){
                fread(bookPtrObj,sizeof(struct book),1,bookFilePtr);   
		cout << bookPtrObj->name << "s1"<< endl;
		cout << bookPtrObj->publisher << "s2"<< endl;
		cout << bookPtrObj->author << "s3" <<endl;
		cout << bookPtrObj->stock << endl;
		cout << bookPtrObj->translation << endl;
		cout << bookPtrObj->trasnlator << "s4" <<endl;
		cout << bookPtrObj->delayDays << endl;
		cout << bookPtrObj->delayPay << endl;
		cout << "***************************************************" << endl;
		fseek(bookFilePtr,counter * sizeof(struct book) ,SEEK_SET); // seek to next data
		counter ++;
	}

It prints for once all of my file , but didn't quit from my loop. and my func continue to print last data in file.How i do?
my fopen , opened it with "rw+" mode.
Last edited on
I solved it , i replaced while (!feof ) with while (fread)....
Topic archived. No new replies allowed.