problem with getline

  • Thread starter ankit.kumar.agarwal
  • Start date
A

ankit.kumar.agarwal

I am facing a problem with getline
I am reading a text file with a getline function the lines can have
'|' as separator.

everything works OK but in case if i have 2 delimitors in file '234||
dfdg' so here
my program does not go beyond the 2nd '|'.
i am using ifstream to read the file.
somehow check for eof() gets passed although end of file is not there.
i am using
mFile->getline(mBuf,Length, Delimiter);



please help me.
 
J

John Harrison

I am facing a problem with getline
I am reading a text file with a getline function the lines can have
'|' as separator.

everything works OK but in case if i have 2 delimitors in file '234||
dfdg' so here
my program does not go beyond the 2nd '|'.
i am using ifstream to read the file.
somehow check for eof() gets passed although end of file is not there.
i am using
mFile->getline(mBuf,Length, Delimiter);



please help me.

Misunderstanding how getline, operator>> and end of file works is one of
the commonest errors we see on this group. But we cannot help you unless
you post the code that doesn't work. We are not psychic.

john
 
A

ankit.kumar.agarwal

Misunderstanding how getline, operator>> and end of file works is one of
the commonest errors we see on this group. But we cannot help you unless
you post the code that doesn't work. We are not psychic.

john- Hide quoted text -

- Show quoted text -

Can you please tell me that how getline behaves when it sees 2
delimiters sid by side , can it cause
eof() to become true , is it normal
and is their any solution to this
 
J

John Harrison

Can you please tell me that how getline behaves when it sees 2
delimiters sid by side , can it cause
eof() to become true , is it normal
and is their any solution to this

Each delimiter is the end of a different line.

getline cause eof to become true when it reads past the end of a file.

If you cannot post the code, then we cannot help you. The mistake you
are making is different from what you think it is. Post the code so me
or someone else can tell you what the mistake you are making is.

john
 
A

ankit.kumar.agarwal

Each delimiter is the end of a different line.

getline cause eof to become true when it reads past the end of a file.

If you cannot post the code, then we cannot help you. The mistake you
are making is different from what you think it is. Post the code so me
or someone else can tell you what the mistake you are making is.

john- Hide quoted text -

- Show quoted text -
will getline set some error bit if it could not read any character
bacause it found a deleimiter
as the first character.

Please suggest How to post a code of 1000+ lines having dependencies
on multiple files
 
J

John Harrison

will getline set some error bit if it could not read any character
bacause it found a deleimiter
as the first character.
No.


Please suggest How to post a code of 1000+ lines having dependencies
on multiple files

Remove the parts that aren't working and post those. It helps if you
post a complete program but if that's not possible then posting some
code will give someone some chance of spotting an error.

john
 
G

Gavin Deane

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,962
Messages
2,570,134
Members
46,692
Latest member
JenniferTi

Latest Threads

Top