/* 创建空洞文件 */
#include
#include
#include
#include
#define MAXLINE 4096
int main(int argc,char ** argv)
{
int fd;
char buf1[MAXLINE] = {'h','e','l','l','o'};
char buf2[MAXLINE] = {'w','o','r','l','d'};
fd = open("temp1",O_CREAT|O_RDWR,0644);
write(fd,buf1,strlen(buf1));
lseek(fd,1024,SEEK_SET);
write(fd,buf2,strlen(buf2));
return 0;
}
debian:/home/linux/unix# !cc
cc 3-2.c
debian:/home/linux/unix# ./a.out
debian:/home/linux/unix# ls -lt|grep temp
-rw-r--r-- 1 root root 1029 02-24 11:16 temp
debian:/home/linux/unix# od -c temp
0000000 h e l l o \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
0000020 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0 \0
*
0002000 w o r l d
0002005
debian:/home/linux/unix#
阅读(732) | 评论(0) | 转发(0) |