problem with getline

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • ankit.kumar.agarwal@gmail.com

    #1

    problem with getline

    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,L ength, Delimiter);



    please help me.

  • John Harrison

    #2
    Re: problem with getline

    ankit.kumar.aga rwal@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,L ength, Delimiter);
    >
    >
    >
    please help me.
    >
    Misunderstandin g 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

    Comment

    • ankit.kumar.agarwal@gmail.com

      #3
      Re: problem with getline

      On Mar 10, 1:49 am, John Harrison <john_androni.. .@hotmail.comwr ote:
      ankit.kumar.aga r...@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,L ength, Delimiter);
      >
      please help me.
      >
      Misunderstandin g 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




      Comment

      • John Harrison

        #4
        Re: problem with getline

        ankit.kumar.aga rwal@gmail.com wrote:
        On Mar 10, 1:49 am, John Harrison <john_androni.. .@hotmail.comwr ote:
        >
        >>ankit.kumar.a gar...@gmail.co m 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,L ength, Delimiter);
        >>
        >>>please help me.
        >>
        >>Misunderstand ing 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

        Comment

        • ankit.kumar.agarwal@gmail.com

          #5
          Re: problem with getline

          On Mar 10, 11:59 am, John Harrison <john_androni.. .@hotmail.com>
          wrote:
          ankit.kumar.aga r...@gmail.com wrote:
          On Mar 10, 1:49 am, John Harrison <john_androni.. .@hotmail.comwr ote:
          >
          >ankit.kumar.ag ar...@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,L ength, Delimiter);
          >
          >>please help me.
          >
          >Misunderstandi ng 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

          Comment

          • John Harrison

            #6
            Re: problem with getline

            ankit.kumar.aga rwal@gmail.com wrote:
            On Mar 10, 11:59 am, John Harrison <john_androni.. .@hotmail.com>
            wrote:
            >
            >>ankit.kumar.a gar...@gmail.co m wrote:
            >>
            >>>On Mar 10, 1:49 am, John Harrison <john_androni.. .@hotmail.comwr ote:
            >>
            >>>>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.
            >>
            >>>>>everythi ng 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,L ength, Delimiter);
            >>
            >>>>>please help me.
            >>
            >>>>Misundersta nding 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

            Comment

            • Gavin Deane

              #7
              Re: problem with getline

              On 11 Mar, 17:49, ankit.kumar.aga r...@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.


              Also


              Gavin Deane

              Comment

              Working...