Menu

How to clear file's text?

2002-09-29
2012-09-26
  • Nobody/Anonymous

    Hello, my question is how to clear the file's previous text, so when I start writing to the file it will be empty and there will be no overwriting? I know how to clear screen (I've seen this on forum), but I don't know this for the file. My file is for input and output. Thanks, Franjo

     
    • Nobody/Anonymous

      I suggest you read up on file modes ie. read, write, read/write, append etc. If your using C, study up on FILE* (file pointers), or fstream for C++(but i'd leave that for the momment).

      LK

       
    • Nobody/Anonymous

      By default when opening a file ( ofstream fout("test.txt")  )  it is deleated and replaced if it already exists.

      Curtis

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.