컴퓨터/언어,프로그래밍
hole있는 파일 생성(creat, write, lseek)
스노우볼^^
2009. 5. 27. 10:14
/*
hole있는 파일 생성
creat, write, lseek
*/
#include <unistd.h>
#include <fcntl.h>
int main(void)
{
int fd;
//파일만들다
fd = creat("holefile", 0644);
//만든파일에 문자 쓴다.
write(fd, "hello", 5);
//현재 위치에서 10번째 뒤로 이동
lseek(fd, 10, SEEK_CUR);
//문자쓴다.
write(fd, "world", 5);
//처음 시작점 부터 8192만큼 뒤로 이동
lseek(fd, 8192, SEEK_SET);
//문자 쓴다.
write(fd, "bye", 3);
close(fd);
return 0;
}
[출처] hole있는 파일 생성(creat, write, lseek)|작성자 지상렬