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.
現在のオフセットで開いているファイルを切り捨てる Linux API はありますか? lseek() の後に ftruncate() を実行できますが、システム コールを保存しようとしていました。
ftell() はあなたの友達です:
/* do operations on file, such as fread() or fwrite() */ curpos = ftell(filehandle); if (result = ftruncate(filehandle, curpos)) { /* handle the error condition, examine errno etc */ exit(errno); }