Using fwrite() deletes data

前端 未结 1 1642
野趣味
野趣味 2021-01-24 06:29

I wrote a very simple file corruptor for fun, but to my surprise, the \"corrupted\" file ends up being smaller in size than the original.

Here is the corruption function

1条回答
  •  被撕碎了的回忆
    2021-01-24 07:06

    output = fopen(outputname, "w+");
    

    This deletes the contents of the file, To open the file for reading and writing without deleting the contents, use mode "r+".

    0 讨论(0)
提交回复
热议问题