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. Inserting String in middle of File

Inserting String in middle of File

Scheduled Pinned Locked Moved C / C++ / MFC
json
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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    I want to modify a text file programmatically. Suppose it is huge in size and my desired operation on it is to modify it by adding some text in middle of File. Is there any other except the traditional one, I always use i.e. to insert the string and shift all the rest that follow the string. Can some1 please tell me a fast method other than it.

    J T 2 Replies Last reply
    0
    • L Lost User

      I want to modify a text file programmatically. Suppose it is huge in size and my desired operation on it is to modify it by adding some text in middle of File. Is there any other except the traditional one, I always use i.e. to insert the string and shift all the rest that follow the string. Can some1 please tell me a fast method other than it.

      J Offline
      J Offline
      Johnny
      wrote on last edited by
      #2

      It depends what you mean by 'modify'. If you are inserting new text then no, there is no other way than rewriting everything after the new string. If you are just modifying existing text then you can overwrite the part of the file you are interested in.

      1 Reply Last reply
      0
      • L Lost User

        I want to modify a text file programmatically. Suppose it is huge in size and my desired operation on it is to modify it by adding some text in middle of File. Is there any other except the traditional one, I always use i.e. to insert the string and shift all the rest that follow the string. Can some1 please tell me a fast method other than it.

        T Offline
        T Offline
        Tim Zorn
        wrote on last edited by
        #3

        u could always read the file, split it in half where u want to write then rewrite that to the file in the order u want i am also curious as to how to change where the file is being written/overwritten to

        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