But I never said that you should pass in the return value of read(...) to cout!Besides, you must open this file for reading before trying to read anything!Code:for(int i = 0; i< 4;i++) { file.read(reinterpret_cast<char*>(&yourCat), sizeof(struct Cat)); cout << setw(10) << left << yourCat.name << "\t"; cout << yourCat.age <<endl; }





Victor Nijegorodov
Reply With Quote