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. Erasing the contents of a file..

Erasing the contents of a file..

Scheduled Pinned Locked Moved C / C++ / MFC
help
3 Posts 3 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.
  • P Offline
    P Offline
    pl_kode
    wrote on last edited by
    #1

    My program is creating a file named file.prop with one of the following in it...

    ...
    Max records=10
    Temp size=94

    Next, I parse this file line by line and get the values...
    As I finish reading a line from a file I want to erase that line from the file for e.g. I read Temp size=94. After reading this line I want to erase it from file.prop . How can this be done. Please help me out.

    THANKS..

    M D 2 Replies Last reply
    0
    • P pl_kode

      My program is creating a file named file.prop with one of the following in it...

      ...
      Max records=10
      Temp size=94

      Next, I parse this file line by line and get the values...
      As I finish reading a line from a file I want to erase that line from the file for e.g. I read Temp size=94. After reading this line I want to erase it from file.prop . How can this be done. Please help me out.

      THANKS..

      M Offline
      M Offline
      Michael Schubert
      wrote on last edited by
      #2

      Without knowing your code, hard to say. In general, if you are reading the file line by line do the following: Write each line you read to a temporary file. Once you reach the line you want to delete, skip it. Once your done reading, rename the temporary file overwriting the original file.

      modified on Friday, May 16, 2008 6:57 AM

      1 Reply Last reply
      0
      • P pl_kode

        My program is creating a file named file.prop with one of the following in it...

        ...
        Max records=10
        Temp size=94

        Next, I parse this file line by line and get the values...
        As I finish reading a line from a file I want to erase that line from the file for e.g. I read Temp size=94. After reading this line I want to erase it from file.prop . How can this be done. Please help me out.

        THANKS..

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

        pl_kode wrote:

        As I finish reading a line from a file I want to erase that line from the file

        Why? What is it that you are trying to avoid?

        "Love people and use things, not love things and use people." - Unknown

        "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

        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