• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
  • lseek 和 write

    發表于:2007-05-25來源:作者:點擊數: 標簽:lseekwrite關系驗證
    lseek 和 write //驗證lseek和write的關系 //無論以何種方式打開文件,lseek都可以在文件中seek到任意的位置 //write寫的方式和open函數的方式有直接的關系 //如果open函數打開的時候不用O_APPEND參數,先seek到任意位置,可以在文件中的某個位置 //然后writ
    lseek 和 write

    //驗證lseek和write的關系

    //無論以何種方式打開文件,lseek都可以在文件中seek到任意的位置
    //write寫的方式和open函數的方式有直接的關系


    //如果open函數打開的時候不用O_APPEND參數,先seek到任意位置,可以在文件中的某個位置
    //然后write,則沖調文件里之前的內容

    //如果open函數打開的時候用O_APPEND參數,無論seek到任意位置,write都是從文件的末尾開始寫的

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

    char buf[] = "$$$$$$$$$$";

    int main( void )
    {  
     int fd;

     if( ( fd = open("file",O_RDWR|O_APPEND ) ) < 0 )
     {
      printf("Open Error!\n");
      exit(1);
     }
     if( lseek( fd, 10, SEEK_SET ) ==-1 )
     { 
      printf( "Seek Error!\n" );
      exit(1);
     }
     write(fd,buf,10);
     exit(0);
    }

    原文轉自:http://www.kjueaiud.com

    評論列表(網友評論僅供網友表達個人看法,并不表明本站同意其觀點或證實其描述)
    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>