logoalt Hacker News

Joker_vD • today at 11:33 AM • 1 reply • view on HN

Such a baffling option, to be fair, I don't think I've ever used it. Like, what's even the point?


Replies

vconnor • today at 12:41 PM

Why would one would like to truncate an existing file? To overwrite it. It's a very common use case.

What I have never found any use for personally is opening a file in read-write mode, while also truncating it, which is the full extent of w+ behaviour. I cannot think of many reasons to have an output stream to also function as an input.