Created
September 6, 2014 09:38
-
-
Save hiroshiro/5ea58be44a674fd7e909 to your computer and use it in GitHub Desktop.
関数lseekをテスト。16384バイトシーク
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "apue.h" | |
#include <fcntl.h> | |
char buf1[] = "abcdefghij"; | |
char buf2[] = "ABCDEFGHIJ"; | |
int | |
main(void) | |
{ | |
int fd; | |
if((fd = creat("file.hole", FILE_MODE)) < 0) | |
err_sys("creat error"); | |
if (write(fd, buf1, 10) != 10) | |
err_sys("bun1 write error"); | |
/* オフセットはここで 10 */ | |
if (lseek(fd, 16384, SEEK_SET) == -1) | |
err_sys("lseek error"); | |
/* オフセットはここで 16384 */ | |
if (write(fd, buf2, 10) != 10) | |
err_sys("buf2 write error"); | |
/* オフセットはここで 16394 */ | |
exit(0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment