Re: [Dev-C++] Problem with file reading
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
From: Per W. <pw...@ia...> - 2009-12-30 15:47:57
|
Do test the result of your fgets() calls. Don't expect that feof() will look ahead to see that the next fgets() will fail to find more data. /pwm On Wed, 30 Dec 2009, Jan Mura wrote: > Hello, > I've got problems with reading a file. > I'm working on a connected list, but would like to store the list. > The source code for writing to a file: > > do > { > fputs (member -> name, filelist); > fputs ("\n", filelist); > fputs (member -> number, filelist); > fputs ("\n", filelist); > > member = member -> next; > } > while (member != temp -> next); > > > ...seems it works correctly > > Reading from a file is: > > do > { > fgets (user_name, 50, filelist); > fgets (user_number, 50, filelist); > in_user(&pointer_to_user, user_name, user_number); > } > while (!feof(filelist)); > > And it seems it reads one more thing, so then in the list is one more > member > > Thank you for a help in advance. > > Jan Mura > > > > > ------------------------------------------------------------------------------ > This SF.Net email is sponsored by the Verizon Developer Community > Take advantage of Verizon's best-in-class app development support > A streamlined, 14 day to market process makes app distribution fast and easy > Join now and get one step closer to millions of Verizon customers > http://p.sf.net/sfu/verizon-dev2dev > _______________________________________________ > Dev-cpp-users mailing list > Dev...@li... > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > |