Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 23rd, 2007, 10:25 PM   #11
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Re: Structures and Reading from File

@ccfc: I'm sorry, but writing a textual "end of file" is a trash approach to the condition. You're not alone, however. Even MS, in their "text" mode, use content (ctrl-Z) to form an "end of file" character.

The problem with this approach, aside from being unnecessary, is that one now has an entity that has to be dealt with in the case of appends. See the MS docs for the caveats.

EOF is a condition. The various library functions deal with it and make its presence known in various ways. Use those and other people will know how to deal with your code. It's a professional thing.

@null_ptr: Please do not just repeat previous responses. The OP is writing in C++; there's no good reason, in this case, to strain at a gnat and use C comparison functions. We get it that you're an 11-year old genius, okay?
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Nov 23rd, 2007, 10:38 PM   #12
null_ptr0
12 years old
 
Join Date: Nov 2007
Posts: 105
Rep Power: 0 null_ptr0 is an unknown quantity at this point
Re: Structures and Reading from File

Quote:
Originally Posted by DaWei View Post
@null_ptr: Please do not just repeat previous responses. The OP is writing in C++; there's no good reason, in this case, to strain at a gnat and use C comparison functions. We get it that you're an 11-year old genius, okay?
haha, I didn't realize I repeated a previous response.
null_ptr0 is offline   Reply With Quote
Old Nov 23rd, 2007, 10:59 PM   #13
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Re: Structures and Reading from File

Try reading the thread....
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old Nov 24th, 2007, 1:55 PM   #14
peaceofpi
hi: for(;;) goto hi;
 
peaceofpi's Avatar
 
Join Date: Jun 2006
Posts: 115
Rep Power: 3 peaceofpi is on a distinguished road
Send a message via AIM to peaceofpi Send a message via MSN to peaceofpi
Re: Structures and Reading from File

Quote:
Originally Posted by null_ptr0 View Post
try calling
strcmp(personInfo[count].last_name.data(), end_of_file.data())
and using the preprocessor statement
c++ Syntax (Toggle Plain Text)
  1. #include <string.h>
Silly me, I thought we were in the C++ forum.

edit: Pardon my speed, read the whole thing and replied without refreshing!
__________________
How do you play Religious Roulette?
Stand around in a circle and blaspheme till someone gets struck by lightning.
peaceofpi is offline   Reply With Quote
Old Nov 24th, 2007, 6:57 PM   #15
ccfc1986
Newbie
 
Join Date: Nov 2007
Posts: 4
Rep Power: 0 ccfc1986 is on a distinguished road
Re: Structures and Reading from File

Dawei - Thanks for your help. I realize what i did wrong - and i corrected my mistake. I completely forgot that i can test for such a thing without doing what i did. So once again - thanks again for the help.

Cheers all.
ccfc1986 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing Array structures to Linked Lists? kalulu C 4 Nov 29th, 2005 7:33 AM
C files and structures Princeck C++ 2 Feb 24th, 2005 3:09 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 5:23 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC