Menu

How to clear file's text?

2002-09-29
2026-01-24
  • 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

       
  • Viki Denver

    Viki Denver - 2026-01-24

    I’ve been working on a few coding projects lately, and I realized that no matter how much you focus on your code, the little write-ups, comments, and documentation always end up full of tiny mistakes. It’s surprisingly distracting when you’re trying to make sense of your own notes later. I started using this proofreading tool I found—https://cabina.ai/tools/text-enhancer it actually catches things I’d completely overlook, like awkward phrasing or missing punctuation. It doesn’t feel like overkill, just smooths out your text so you can focus more on the coding itself. Definitely saved me some headaches.

     

    Last edit: Viki Denver 2026-01-24

Log in to post a comment.

MongoDB Logo MongoDB