append to file and delete from file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sokoun
    New Member
    • Sep 2007
    • 30

    append to file and delete from file

    Hi all,

    I want to append a word or phrases to file without replce the old data in the file. could you give a sample program for me?

    another one, i want to delete a spacific work or phrases in the file, how to write this program? with a sample one.

    thanks.
  • Atli
    Recognized Expert Expert
    • Nov 2006
    • 5062

    #2
    Hi.

    You can use the fopen() function with "a" as a second parameter to append to the end of a file.

    To delete from the file it would probably be best to read it into a variable and use some of the string functions to edit it.
    Unless it is a huge file, in which case you would probably need to read it in portions and overwrite it as you go.

    Comment

    • pbmods
      Recognized Expert Expert
      • Apr 2007
      • 5821

      #3
      Heya, Sokoun.

      If you are reading and writing large amounts of data to this file, you might want to consider using a database as a more robust solution.

      Comment

      Working...