Yet another C++ problem...
Author | Topic: Yet another C++ problem... |
---|---|
Master
Member # 4614
|
written Saturday, July 23 2005 10:50
Profile
Homepage
Since I'm kind of stuck again. :/ This time it has to do with reading and writing classes to and from files. Here's what I have: TeamList is a linked list of teams I created as a class that contains a bunch of other stuff, but I doubt this has anything to do with the problem at hand. What I'm trying to do is be able to save a TeamList to a file and then be able to reopen it again at a later time. writefile() creates a file with a user-specified name. readfile() reads the file and displays a menu of what to do with that file. writefile() seems to work fine; it creates a file and everything, but when I try to read the file, it gives me a whole bunch of irrevelant characters and then crashes. The menu is not displayed. Anyone know what I could have done wrong? -------------------- -ben4808 For those who love to spam: CSM Forums RIFQ Posts: 3360 | Registered: Friday, June 25 2004 07:00 |
Post Navel Trauma ^_^
Member # 67
|
written Saturday, July 23 2005 11:35
Profile
Homepage
The problem is that a linked list is a load of pointers, and you can't sensibly write pointers to a file like that. You have to separately write each member of the linked list, and your reading routine then has to take them and join them up. -------------------- Barcoorah: I even did it to a big dorset ram. desperance.net - Don't follow this link Posts: 1798 | Registered: Thursday, October 4 2001 07:00 |
Master
Member # 4614
|
written Saturday, July 23 2005 12:24
Profile
Homepage
Actually, the TeamList class contains another linked list which stores all the players on that team, so... You're saying that doing what I want to do would be very complicated. -------------------- -ben4808 For those who love to spam: CSM Forums RIFQ Posts: 3360 | Registered: Friday, June 25 2004 07:00 |
Post Navel Trauma ^_^
Member # 67
|
written Saturday, July 23 2005 12:44
Profile
Homepage
Basically, yes. -------------------- Barcoorah: I even did it to a big dorset ram. desperance.net - Don't follow this link Posts: 1798 | Registered: Thursday, October 4 2001 07:00 |