Need Help in Reading characters from a text file

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Feb 2006
Posts: 486
Reputation: Bench has a spectacular aura about Bench has a spectacular aura about Bench has a spectacular aura about 
Solved Threads: 48
Bench's Avatar
Bench Bench is offline Offline
Posting Pro in Training

Re: Need Help in Reading characters from a text file

 
0
  #11
Apr 20th, 2006
It's probably to do with the fact that your while loop is reading until EOF is set - in C++ this is the wrong way to do it, because your program will crash reading past the end of openfile (which is actually a stream, not a file). instead, use while (openfile) which will continue as long as there is data in the stream.
Reply With Quote Quick reply to this message  
Join Date: Apr 2006
Posts: 11
Reputation: tuannie is an unknown quantity at this point 
Solved Threads: 0
tuannie tuannie is offline Offline
Newbie Poster

Re: Need Help in Reading characters from a text file

 
0
  #12
Apr 20th, 2006
Originally Posted by WolfPack
What is the error message? What is line number 6? We can't go on counting you know...When you say execute do you mean compiling or running the program?
I mean compiling it, this is what I get:
  1. ****************************************************
  2.  
  3. Please wait...
  4.  
  5. The following file tolldata.txt has been found.
  6.  
  7. ****************************************************
  8.  
  9.  
  10. Error - Invalid or miss match Station ID record.
  11. Please refer to line 6 of tolldata.txt text file.
  12.  
  13. Press any key to continue . . .
Reply With Quote Quick reply to this message  
Join Date: Jun 2005
Posts: 1,496
Reputation: WolfPack has a spectacular aura about WolfPack has a spectacular aura about WolfPack has a spectacular aura about 
Solved Threads: 104
Moderator
WolfPack's Avatar
WolfPack WolfPack is offline Offline
Mentally Challenged Mod.

Re: Need Help in Reading characters from a text file

 
0
  #13
Apr 20th, 2006
Originally Posted by tuannie
I mean compiling it, this is what I get:
  1. ****************************************************
  2.  
  3. Please wait...
  4.  
  5. The following file tolldata.txt has been found.
  6.  
  7. ****************************************************
  8.  
  9.  
  10. Error - Invalid or miss match Station ID record.
  11. Please refer to line 6 of tolldata.txt text file.
  12.  
  13. Press any key to continue . . .
Bench is right. You are reading past the EOF. And it is not compiling. You are executing ( running ) the program. This is a runtime error.
バルサミコ酢やっぱいらへんで
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,396
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1466
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Still Learning

Re: Need Help in Reading characters from a text file

 
0
  #14
Apr 20th, 2006
>>Bench is right. You are reading past the EOF.

That's what I said in my original post -- that loop will not work the way it is coded. If some people (OP) would learn to read :rolleyes:
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC