利用lseek製作任意大小的文件

#include <sys/types.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>

int main(int argc,char *argv[])
{
    int fd = open(argv[1],O_RDWR | O_TRUNC | O_CREAT,0644);
	char buf[100] = {0};
    int n;
    //printf("Please input the size:\n");
    //scanf("%d",&n);
    int offset = lseek(fd,atoi(argv[2]) - 1,SEEK_SET);
    write(fd," ",1);
    close(fd);
	return 0;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章