Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
.txt ファイルの内容を削除して空のファイルにするか、ファイルを完全に削除するにはどうすればよいですか? .txt ファイルから読み込んでいますが、前回実行したときの内容を削除しないと、説明したい結果が省略されます。
ファイルの名前が だとするとto_be_deleted.txt、次のコマンドを使用してファイルを完全に削除できます。
to_be_deleted.txt
delete 'to_be_deleted.txt';
一方、単純に内容をクリアしたい場合はfopen、次のように書き込み属性を使用して開くだけです。
fopen
fopen('to_be_deleted.txt','w');