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. delete one character in file

delete one character in file

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
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.
  • S Offline
    S Offline
    six_billion
    wrote on last edited by
    #1

    I use Visual C++ to program. Can I delete one character in one file without use a tempFile? And How? For example, - my file contains: "Life is so short"; - the file pointer is at the beginning of file - after I open file for reading & writing, the file contains "ife s o hort"; thanks do not understand everything

    D M 2 Replies Last reply
    0
    • S six_billion

      I use Visual C++ to program. Can I delete one character in one file without use a tempFile? And How? For example, - my file contains: "Life is so short"; - the file pointer is at the beginning of file - after I open file for reading & writing, the file contains "ife s o hort"; thanks do not understand everything

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

      six_billion wrote: Can I delete one character in one file without use a tempFile? And How? Yes. In summary:* Open file for reading

      • Read entire file into buffer

      • Close file

      • Locate and delete character from buffer

      • Open file for writing

      • Write buffer to file

      • Close file


        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

      1 Reply Last reply
      0
      • S six_billion

        I use Visual C++ to program. Can I delete one character in one file without use a tempFile? And How? For example, - my file contains: "Life is so short"; - the file pointer is at the beginning of file - after I open file for reading & writing, the file contains "ife s o hort"; thanks do not understand everything

        M Offline
        M Offline
        Maximilien
        wrote on last edited by
        #3

        well, you open the file, read the data, close the file, modify the data and write back the data into it. you can't directly modify a file. ( afaik ).


        Maximilien Lincourt Your Head A Splode - Strong Bad

        N 1 Reply Last reply
        0
        • M Maximilien

          well, you open the file, read the data, close the file, modify the data and write back the data into it. you can't directly modify a file. ( afaik ).


          Maximilien Lincourt Your Head A Splode - Strong Bad

          N Offline
          N Offline
          Neville Franks
          wrote on last edited by
          #4

          Maximilien wrote: you can't directly modify a file. ( afaik ). Well you can using a memory mapped file, but this is a bit of trickery.;) Neville Franks, Author of ED for Windows www.getsoft.com and Surfulater www.surfulater.com "Save what you Surf"

          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