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. Trouble reading from a file.

Trouble reading from a file.

Scheduled Pinned Locked Moved C / C++ / MFC
c++securityhelp
4 Posts 4 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.
  • R Offline
    R Offline
    rassad
    wrote on last edited by
    #1

    I have built a program in using VC++ 6.0 that will parse out the URL's from an AOL .pfc(personal filling cabient) file. The .pfc is full of garbage(terminators, little boxes kinda looks like encryption, misc chars, and URL's) The program works just fine on most .pfc files. The problem Im having with some .pfc files are that the program will not read the entire file. I have reason to believe that my troubles lie in the eof(end of file) terminating condition. Here is the code that reads in the file char by char adding it to a string: if(! inStream.eof()) { if(! iscntrl(cSymbol)) m_strBeforeParse += (CString)cSymbol; inStream.get(cSymbol); } For some reason the eof function is returning "true" when it reaches a certain part of the file. This certain part of the file is the little boxes in the file that I described earlier as what I thought looked like encyrption. If I erase these little boxes, I can read whole filwe just fine. If anyone has any ideas Id be greatful to hear them.

    P D 2 Replies Last reply
    0
    • R rassad

      I have built a program in using VC++ 6.0 that will parse out the URL's from an AOL .pfc(personal filling cabient) file. The .pfc is full of garbage(terminators, little boxes kinda looks like encryption, misc chars, and URL's) The program works just fine on most .pfc files. The problem Im having with some .pfc files are that the program will not read the entire file. I have reason to believe that my troubles lie in the eof(end of file) terminating condition. Here is the code that reads in the file char by char adding it to a string: if(! inStream.eof()) { if(! iscntrl(cSymbol)) m_strBeforeParse += (CString)cSymbol; inStream.get(cSymbol); } For some reason the eof function is returning "true" when it reaches a certain part of the file. This certain part of the file is the little boxes in the file that I described earlier as what I thought looked like encyrption. If I erase these little boxes, I can read whole filwe just fine. If anyone has any ideas Id be greatful to hear them.

      P Offline
      P Offline
      Peter Weyzen
      wrote on last edited by
      #2

      how are you opening the file? What flags do you pass in to the file constructor/open code? ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Peter Weyzen Staff Engineer Santa Cruz Networks

      1 Reply Last reply
      0
      • R rassad

        I have built a program in using VC++ 6.0 that will parse out the URL's from an AOL .pfc(personal filling cabient) file. The .pfc is full of garbage(terminators, little boxes kinda looks like encryption, misc chars, and URL's) The program works just fine on most .pfc files. The problem Im having with some .pfc files are that the program will not read the entire file. I have reason to believe that my troubles lie in the eof(end of file) terminating condition. Here is the code that reads in the file char by char adding it to a string: if(! inStream.eof()) { if(! iscntrl(cSymbol)) m_strBeforeParse += (CString)cSymbol; inStream.get(cSymbol); } For some reason the eof function is returning "true" when it reaches a certain part of the file. This certain part of the file is the little boxes in the file that I described earlier as what I thought looked like encyrption. If I erase these little boxes, I can read whole filwe just fine. If anyone has any ideas Id be greatful to hear them.

        D Offline
        D Offline
        Dean Goodman
        wrote on last edited by
        #3

        I've had the same problem before (just dealt with it today in fact). The little boxes you see are non-printing ascii characters. When I ran into the problem, the char was decimal 26, hex 1A. You are reading a binary file as a text file, and that's why you are having a problem. If you read the file as binary, you won't have the EOF problem, you'll just have to change your code a little bit. --Dean

        A 1 Reply Last reply
        0
        • D Dean Goodman

          I've had the same problem before (just dealt with it today in fact). The little boxes you see are non-printing ascii characters. When I ran into the problem, the char was decimal 26, hex 1A. You are reading a binary file as a text file, and that's why you are having a problem. If you read the file as binary, you won't have the EOF problem, you'll just have to change your code a little bit. --Dean

          A Offline
          A Offline
          Anonymous
          wrote on last edited by
          #4

          Thank's Dean -Rocky:)

          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