#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
int main(int argc, const char* argv[])
{
if(argc < 3)
{
fprintf(stderr, "%s <filename> <size>\n", argv[0]);
exit(1);
}
long int len = strtol(argv[2], NULL, 10);
int new_len = truncate(argv[1], len);
if(new_len == -1)
{
perror("truncate");
exit(1);
}
return 0;
}
Linux下C中trunc函数
最新推荐文章于 2024-07-28 16:11:05 发布