473,320 Members | 1,939 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

any other way to recognize end of file.....

hi all,

i have a doubt regarding checking the condition for the endoffile in a loop

generally we were using
while(!fin.eof())

but due to some reason it was not recognizing the eof
checked out all the possible errors
but couldn trace out

is there any other way than eof
to check for end of file.................


thanks in advance..................
Aug 8 '07 #1
4 1835
hi all,

i have a doubt regarding checking the condition for the endoffile in a loop

generally we were using
while(!fin.eof())

but due to some reason it was not recognizing the eof
checked out all the possible errors
but couldn trace out

is there any other way than eof
to check for end of file.................


thanks in advance..................
I think You can try with a Null character at the end. '\0'

I am not sure of this but I feel the last character in the file
may be NULL; the same technique is used by eof as well.

Regards,
Girish.
Aug 8 '07 #2
vermarajeev
180 100+
Did you try clearing the stream?
I think the stream is corrupted.

I dont know much about C but in C++ there is a flag called clear which resets all the flag of the stream used.
Something like this
Expand|Select|Wrap|Line Numbers
  1. ifstream ifs("text,txt");
  2.   if( !ifs.isopen() ) 
  3.           return -1;
  4.   while( !ifs.eof() ) 
  5.    {
  6.         //read the data 
  7.         //check if the stream is corrupted using if( ifs.isgood() ) something I'm not            //sure
  8.         ifs.clear();
  9.    }
Aug 8 '07 #3
thanks a lot rajeev and girish ....
that answers my question.
Aug 8 '07 #4
weaknessforcats
9,208 Expert Mod 8TB
You probably need a \n as the final line of the file.
Aug 8 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: pacs34 | last post by:
I just read some stuff about XHTML 2.0 and it sounds fascinating so I have been trying to create a small test doc which has a few graphics files but whenever I submit it to the W3 validator I get...
0
by: Joel Burton | last post by:
On Wed, Aug 06, 2003 at 12:55:52PM -0400, Joel Burton wrote: Reposting, with some clarification to my request. Thanks to the several responses I received originally. Yes, I know that a...
11
by: Dale | last post by:
How to recognize whether file has XML format or not? Here is the code segment: XmlDocument* pDomDocument = new XmlDocument(); try { pDomDocument->Load(strFileName ) ; } catch(Exception* e) {
0
by: Jeff Ulrich | last post by:
I have two files: C:\ThisIsReal.txt which is a real text document, and C:\ThisIsAShortcut, which is set up via the Windows Explorer to be a shortcut to the real text document. How Can I...
9
by: David Veeneman | last post by:
I'm just getting started with ASP.NET, using VS 2005. As an exercise, I opened the root web site in VS 2005 and created a simple welcome page. I saved the page as Default.aspx and made sure that...
4
by: John Mick | last post by:
Hi, I have renamed aspx to .ret and would like visual studio to recognize .ret file as an aspx file recognize = show designer, intellisense, group up with corresponding codebehind in solution...
3
by: NewToNetworks | last post by:
Hi, hello, help! I am new to networking so please forgive me if this is a simple question. I have been at this for hours to no avail. I"m trying to network my Mac G5, running OSX 10.4.7 Tiger, a...
3
by: prajakta143 | last post by:
Problem Statement: Is there any way to recognize the binary file is in Release mode or in Debug mode from the core file :: Details :: I have core file with me, & wan't to know the mode of...
7
by: MLH | last post by:
If I'm using the following in a procedure... DoCmd.GoToRecord acDataForm, "FormName", acNext, 4 .... how can I recognize the EOF condition? Using GoToRecord, I find myself lost when trying to...
2
by: defn noob | last post by:
from Tkinter import * import os master = Tk() w = Canvas(master, width=800, height=600) print os.path.exists('C:/me/saftarn/desktop/images/blob4.jpg') im = PhotoImage(file =...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.