lseek产生空洞文件
时间:2010-08-26 来源:snailshen
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int main (int argc,char* argv[]){
int fd;
if((fd = creat("file.hole",O_CREAT))<0)
perror("creat error!!");
if(write(fd,"abcdefghij",10)!=10)
perror("wirte error!!");
if(lseek(fd,40,SEEK_SET)==-1)
perror("lseek error!!!");
if(write(fd,"ABCEDFGHIJ",10)!=10)
perror("wirte2 error!!");
return 0;
}
相关阅读 更多 +