Thread: File IO, insert mode?

  1. #1
    Registered User OnionKnight's Avatar
    Join Date
    Jan 2005
    Posts
    555

    File IO, insert mode?

    To my experience, when you work with files they are in replace mode. Text editors have both, how do those work?

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    There is no such thing as insert mode for file I/O. The way text editors do it is they read the entire file in to a bunch of buffers, you make changes to the text in the buffers, it writes the entire file to disk when you save it. So there's no direct insertion. It reads the whole thing and then writes the whole thing again after you make changes.
    If you understand what you're doing, you're not learning anything.

  3. #3
    Registered User OnionKnight's Avatar
    Join Date
    Jan 2005
    Posts
    555
    So how complicated will things get if you want to write something like a function that changes a value in a INI file?

  4. #4
    Anti-Poster
    Join Date
    Feb 2002
    Posts
    1,401
    Not too bad. Read the whole INI file into memory, change the part you want, and then save the whole thing.
    If I did your homework for you, then you might pass your class without learning how to write a program like this. Then you might graduate and get your degree without learning how to write a program like this. You might become a professional programmer without knowing how to write a program like this. Someday you might work on a project with me without knowing how to write a program like this. Then I would have to do you serious bodily harm. - Jack Klein

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A development process
    By Noir in forum C Programming
    Replies: 37
    Last Post: 07-10-2011, 10:39 PM
  2. Formatting a text file...
    By dagorsul in forum C Programming
    Replies: 12
    Last Post: 05-02-2008, 03:53 AM
  3. Post...
    By maxorator in forum C++ Programming
    Replies: 12
    Last Post: 10-11-2005, 08:39 AM
  4. Possible circular definition with singleton objects
    By techrolla in forum C++ Programming
    Replies: 3
    Last Post: 12-26-2004, 10:46 AM