어팬드 - 해당되는 글 1건

#include <fcntl.h>
#include <sys/types.h>
#include <unistd.h>

main(int argc, char *argv[])
{
    int fd;

    if ((fd = open(argv[1], O_WRONLY)) == -1) {
       perror("open failed");
       exit(1);
    }
    /* 읽기/쓰기 포인터가 파일의 끝으로 이동 */
    if (lseek(fd, 0, SEEK_END) == -1) {
       perror("lseek failed");
       exit(1);
    }
    /* 쓰기를 하면 파일의 뒤에 연결 */
    write(fd, " ABCD", 5);
    close(fd);
    exit(0);
}



      c 언어  |  2007. 9. 13. 12:12



sokoban's Blog is powered by Daum & Tattertools