Connecting Tech Pros Worldwide Forums | Help | Site Map

problem with getline

ankit.kumar.agarwal@gmail.com
Guest
 
Posts: n/a
#1: Mar 10 '07
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.


John Harrison
Guest
 
Posts: n/a
#2: Mar 10 '07

re: problem with getline


ankit.kumar.agarwal@gmail.com wrote:
Quote:
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
ankit.kumar.agarwal@gmail.com
Guest
 
Posts: n/a
#3: Mar 10 '07

re: problem with getline


On Mar 10, 1:49 am, John Harrison <john_androni...@hotmail.comwrote:
Quote:
ankit.kumar.agar...@gmail.com wrote:
Quote:
I am facing a problem with getline
I am reading a text file with a getline function the lines can have
'|' as separator.
>
Quote:
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);
>
Quote:
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




John Harrison
Guest
 
Posts: n/a
#4: Mar 10 '07

re: problem with getline


ankit.kumar.agarwal@gmail.com wrote:
Quote:
On Mar 10, 1:49 am, John Harrison <john_androni...@hotmail.comwrote:
>
Quote:
>>ankit.kumar.agar...@gmail.com wrote:
>>
Quote:
>>>I am facing a problem with getline
>>>I am reading a text file with a getline function the lines can have
>>>'|' as separator.
>>
Quote:
>>>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);
>>
Quote:
>>>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
ankit.kumar.agarwal@gmail.com
Guest
 
Posts: n/a
#5: Mar 11 '07

re: problem with getline


On Mar 10, 11:59 am, John Harrison <john_androni...@hotmail.com>
wrote:
Quote:
ankit.kumar.agar...@gmail.com wrote:
Quote:
On Mar 10, 1:49 am, John Harrison <john_androni...@hotmail.comwrote:
>
Quote:
Quote:
>ankit.kumar.agar...@gmail.com wrote:
>
Quote:
Quote:
>>I am facing a problem with getline
>>I am reading a text file with a getline function the lines can have
>>'|' as separator.
>
Quote:
Quote:
>>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);
>
Quote:
Quote:
>>please help me.
>
Quote:
Quote:
>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.
>
Quote:
Quote:
>john- Hide quoted text -
>
Quote:
Quote:
>- Show quoted text -
>
Quote:
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

John Harrison
Guest
 
Posts: n/a
#6: Mar 11 '07

re: problem with getline


ankit.kumar.agarwal@gmail.com wrote:
Quote:
On Mar 10, 11:59 am, John Harrison <john_androni...@hotmail.com>
wrote:
>
Quote:
>>ankit.kumar.agar...@gmail.com wrote:
>>
Quote:
>>>On Mar 10, 1:49 am, John Harrison <john_androni...@hotmail.comwrote:
>>
Quote:
>>>>ankit.kumar.agar...@gmail.com wrote:
>>
Quote:
>>>>>I am facing a problem with getline
>>>>>I am reading a text file with a getline function the lines can have
>>>>>'|' as separator.
>>
Quote:
>>>>>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);
>>
Quote:
>>>>>please help me.
>>
Quote:
>>>>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.
>>
Quote:
>>>>john- Hide quoted text -
>>
Quote:
>>>>- Show quoted text -
>>
Quote:
>>>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.
Quote:
>
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
Gavin Deane
Guest
 
Posts: n/a
#7: Mar 11 '07

re: problem with getline


On 11 Mar, 17:49, ankit.kumar.agar...@gmail.com wrote:
Quote:
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

Closed Thread


Similar C / C++ bytes