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.