transactionsFile.seekp(0,transactionsFile.beg);
transactionsFile.seekg(0,transactionsFile.beg);
while (!transactionsFile.eof()){
transactionsFile.read((char*) &tempTrans, sizeof(Transaction));
tempTrans.amount = 50;
transactionsFile.write((char*) &tempTrans, sizeof(Transaction));
}
transactionsFile.seekg(0,transactionsFile.beg);
while (!transactionsFile.eof()){
transactionsFile.read((char*) &tempTrans, sizeof(Transaction));
cout << tempTrans.transID <<" " << tempTrans.amount <<" "<< tempTrans.creditAcctID <<" "<< tempTrans.debitAcctID <<endl;
}
它不会更改文件中的任何内容。并且在打印时它的打印没有任何原因导致它根本不插入第二个(当我只打印时它工作正常)