#include
#include
#include
#include
// I.制作大小为100个字节的文件 II.制作任意大小的文件 ./faire_file 5155
int main(int argc, char* argv[])
{
int n = 0;
char buf[100] = {};
int fd = open(argv[1], O_RDWR|O_CREAT|O_TRUNC,0755);
int offset = lseek(fd,atoi(argv[2])-1,SEEK_SET);//文件空洞
lseek(fd,10,SEEK_CUR);
write(fd," ",1);
printf("%d\n",offset);
int x = 1;
printf("%d\n",x++ + x++);
/*
int fdr = open(argv[2], O_WRONLY|O_TRUNC|O_CREAT,0755);
if(fd < 0 || fdr < 0)
{
perror("open");
_exit(1);
}
while((n = read(fd,buf,sizeof(buf))) > 0)
{
write(1, buf, n);
write(fdr, buf, n);//n为什么不能改成100?
}
close(fdr);
*/ close(fd);
return 0;
}
阅读(1231) | 评论(0) | 转发(0) |