By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,804 Members | 1,666 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,804 IT Pros & Developers. It's quick & easy.

problem with getline

P: n/a
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.

Mar 10 '07 #1
Share this Question
Share on Google+
6 Replies


P: n/a
an*****************@gmail.com wrote:
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
Mar 10 '07 #2

P: n/a
On Mar 10, 1:49 am, John Harrison <john_androni...@hotmail.comwrote:
ankit.kumar.agar...@gmail.com wrote:
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- 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


Mar 10 '07 #3

P: n/a
an*****************@gmail.com wrote:
On Mar 10, 1:49 am, John Harrison <john_androni...@hotmail.comwrote:
>>ankit.kumar.agar...@gmail.com wrote:
>>>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- 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
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
Mar 10 '07 #4

P: n/a
On Mar 10, 11:59 am, John Harrison <john_androni...@hotmail.com>
wrote:
ankit.kumar.agar...@gmail.com wrote:
On Mar 10, 1:49 am, John Harrison <john_androni...@hotmail.comwrote:
>ankit.kumar.agar...@gmail.com wrote:
>>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- 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

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

Mar 11 '07 #5

P: n/a
an*****************@gmail.com wrote:
On Mar 10, 11:59 am, John Harrison <john_androni...@hotmail.com>
wrote:
>>ankit.kumar.agar...@gmail.com wrote:
>>>On Mar 10, 1:49 am, John Harrison <john_androni...@hotmail.comwrote:
>>>>ankit.kumar.agar...@gmail.com wrote:
>>>>>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- 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

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.
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
Mar 11 '07 #6

P: n/a
On 11 Mar, 17:49, ankit.kumar.agar...@gmail.com wrote:
Please suggest How to post a code of 1000+ lines having dependencies
on multiple files
It is inconceivable that every one of those 1000+ lines is necessary
to reproduce the problem. See Thomas Tutone's post in the following
link (beware line wrap) for a very good explanation of what to do and
why.
http://groups.google.co.uk/group/com...0bb7ea8a166a57

Also
http://www.parashift.com/c++-faq-lit...t.html#faq-5.8

Gavin Deane

Mar 11 '07 #7

This discussion thread is closed

Replies have been disabled for this discussion.