returning to the top of a file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mohaakilla51
    New Member
    • Jul 2007
    • 39

    returning to the top of a file

    OK guys, I Open a file, read it, and close it, but when I reopen it, to read it again, it still sits at the end of file... how to I go back to the top of the file before closing it?
  • mohaakilla51
    New Member
    • Jul 2007
    • 39

    #2
    never mind, I figured that out, I forgot to tell it to clear(). However, I have another question, and rather than start a new topic, How do you set command prompt size from within C++?

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      Originally posted by mohaakilla51
      I forgot to tell it to clear().
      Really??

      I thought you needed to re-open the file using ios_base::beg.

      Comment

      • mohaakilla51
        New Member
        • Jul 2007
        • 39

        #4
        no, it actually went back to the top of the file when I re-opened it, but the eof trigger was still set... I needed to clear the file.

        So what about my second question??

        Comment

        • mattmao
          New Member
          • Aug 2007
          • 121

          #5
          If this is C, then the rewind(); method would take you back to the starting position of the file.

          Comment

          • mattmao
            New Member
            • Aug 2007
            • 121

            #6
            BTW, in C the fopen method should bring you to the starting position every time you call it. I don't know why you have that kind of weird situation after you close the file stream and exit. Anyway, use the rewind() method is to take you back to the starting position of the file in your file process.

            Comment

            • mohaakilla51
              New Member
              • Jul 2007
              • 39

              #7
              OK guys, I figured out that problem, it did actually go back to the start of the file, I just hadn't cleared the eof property, so when I tested, it told me it was at the end of file already.

              On a side note: How do you set the width and height of the command prompt from within C++?

              Comment

              • weaknessforcats
                Recognized Expert Expert
                • Mar 2007
                • 9214

                #8
                Originally posted by mohaakilla51
                On a side note: How do you set the width and height of the command prompt from within C++?
                Start a new thread, please.

                Comment

                • mohaakilla51
                  New Member
                  • Jul 2007
                  • 39

                  #9
                  That I Can Do. Thanks for all the help guys

                  Comment

                  Working...