
Untitled
By: a guest on
May 24th, 2012 | syntax:
None | size: 0.67 KB | hits: 13 | expires: Never
#include "apue.h"
#include <fcntl.h>
#include <string.h>
char buf1[] = "abcdefghij";
char buf2[] = "ABCDEFGHIJ";
int main()
{
int fd = open("file.hole", O_WRONLY | O_CREAT | O_TRUNC, FILE_MODE);
if (fd == -1)
{
err_sys("create file.hole error");
}
if (write(fd, buf1, strlen(buf1)) != strlen(buf1))
{
err_sys("write buf1 error");
}
if (lseek(fd, 16384, SEEK_SET) == -1)
{
err_sys("lseek error");
}
if (write(fd, buf2, strlen(buf2)) != strlen(buf2))
{
err_sys("write buf2 error");
}
return 0;
}