Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CFile::Read

CFile::Read

Scheduled Pinned Locked Moved C / C++ / MFC
question
6 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sam 2006
    wrote on last edited by
    #1

    hi all, i've got a quick question about cfile::read. i just need to get each line of a text file in a loop so i can process each line. can someone show me how, or tell me where to look? thanks in advance, sam kline

    V B K 3 Replies Last reply
    0
    • S Sam 2006

      hi all, i've got a quick question about cfile::read. i just need to get each line of a text file in a loop so i can process each line. can someone show me how, or tell me where to look? thanks in advance, sam kline

      V Offline
      V Offline
      valikac
      wrote on last edited by
      #2

      ReadString() Kuphryn

      S 1 Reply Last reply
      0
      • S Sam 2006

        hi all, i've got a quick question about cfile::read. i just need to get each line of a text file in a loop so i can process each line. can someone show me how, or tell me where to look? thanks in advance, sam kline

        B Offline
        B Offline
        Bram van Kampen
        wrote on last edited by
        #3

        If you look up the Help Files, you will finf: CFile::Read virtual UINT Read( void* lpBuf, UINT nCount ); throw( CFileException ); This will read nCount bytes of raw data from the file object, into your (previously created buffer. I suspect from your question that you already tried this, and somewhere failed to read it back. Easy trap to fall into, takes a bit of history. In the Oldendays, when computers took punchcards, (I punched many a card myself on those rotten noisy machines) a protocol had been established for each computer system, largely and loosely based on the telegraph system. In order to get the machine at the other end of the line to advance to a new line, you had to send two control characters, a Line Feed (LF Char, ASCII 0x0A), to move the Paper forward, and a Carriage Return Char(CR char, ASCII 0x0D) These could be sent in any order, provided both where sent. You can imagine yourself what would happen if either or both where ommitted, the result I can assure you , was generally not legible. In came the VDU Display, a forerunner of the screen you are looking at reading this, and everybody took a step back! What should we send at the End of a Line,( the Windows concept that a document could extend beyond the boundaries of a screen was only in it's infancy). The Discussion was: either a Line Feed, or a CR, Or, ignore the new technology, and treath it as a printer, and send it both, or send it another magical incantation, with aq deeper meaning as to how the result was to be displayed on the screen. All this upset took place at the time when Bill Gates was getting together with a couple of friends, to start off a new business venture.Between then and now, learned committees where formed to formulate software standards, and found invariably, that to land on one side of the debate, or on the other, would invalidate either way years of established practice, so, the issue was shied away from. Also, as software developed, it became less important, compiler writers, and library writers adopted a standard, and, as long as one was aware of the problem, it was quite easy to write a small routine to convert from one to the other. The Weazel code started I think in the ANSI C Library, you open a file as: FILE F =fopen("MyFile.Ext","r+"), and when reading the file thus opened, all twobyte CR-NL chars are converted to a single LF.Conversely, if yoy write a buffer containing a LF, it witt be written to file as a LF-CR combination. This happens automatically, (and as some people would say, underhand). Ofco

        1 Reply Last reply
        0
        • V valikac

          ReadString() Kuphryn

          S Offline
          S Offline
          Sam 2006
          wrote on last edited by
          #4

          thanks for the tip, i used CStdioFile::ReadString sam kline

          1 Reply Last reply
          0
          • S Sam 2006

            hi all, i've got a quick question about cfile::read. i just need to get each line of a text file in a loop so i can process each line. can someone show me how, or tell me where to look? thanks in advance, sam kline

            K Offline
            K Offline
            kiran janaswamy
            wrote on last edited by
            #5

            hi, use StdioFile Class for this Approach and use the Method called ReadLine(...) and if you want to read entire file use ReadHuge(...) instead of Read(...). cheers, uday. uday kiran

            D 1 Reply Last reply
            0
            • K kiran janaswamy

              hi, use StdioFile Class for this Approach and use the Method called ReadLine(...) and if you want to read entire file use ReadHuge(...) instead of Read(...). cheers, uday. uday kiran

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              kiran janaswamy wrote:

              ...if you want to read entire file use ReadHuge(...) instead of Read(...).

              These two methods behave the same in Win32 (i.e., Read() can read entire files).


              "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

              "There is no death, only a change of worlds." - Native American Proverb

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups