May 2019
Beginner
528 pages
29h 51m
English
Formatted data written to a text file cannot be modified without the risk of destroying other data. If the name 'White' needs to be changed to 'Williams' in accounts.txt, the old name cannot simply be overwritten. The original record for White is stored as
300 White 0.00
If you overwrite the name 'White' with the name 'Williams', the record becomes
300 Williams00
The new last name contains three more characters than the original one, so the characters beyond the second “i” in 'Williams' overwrite other characters in the line. The problem is that in the formatted input–output model, records and their fields can vary in size. For example, 7, 14, –117, 2074 and 27383 are all integers and are stored in the same number of ...
Read now
Unlock full access