乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      unix/Linux 低級IO函數(shù)的用法read && write

       lchjczw 2012-04-13
      簡單的讀一個文件:

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

      int main(int argc,char **argv)
      {
              int fd = 0;
              int pid = 0;
              char buffer[20] = {'\0'};
              char *read_buffer[20] = {'\0'};

              //fd = open("/dev/hello",O_RDWR | O_CREAT | O_TRUNC);
              fd = open("/dev/hello",O_RDONLY ); //| O_NONBLOCK);
              printf("fd=%d\n",fd);
              if(fd < 0) {
                      perror("/dev/hello");
                      return -1;
              }

              read(fd,read_buffer,sizeof(read_buffer)-1);
              printf("read_buffer=%s\n",read_buffer);


              close(fd);

              return 0;
      }





      ---

      下面這個就是簡單的寫一個文件 ,
      #include <unistd.h>
      #include <sys/types.h>
      #include <sys/stat.h>
      #include <fcntl.h>

      int main(int argc,char **argv)
      {
              int fd = 0;
              int pid = 0;
              char buffer[20] = {'\0'};
              char write_buffer[20] = {'\0'};

              strcpy(write_buffer,"zhanglinbao");

              fd = open("/dev/hello",O_RDWR | O_CREAT | O_TRUNC);
              //fd = open("/dev/hello",O_RDONLY);
              printf("fd=%d\n",fd);
              if(fd < 0) {
                      perror("/dev/hello");
                      return -1;
              }

              write(fd,write_buffer,sizeof(write_buffer)-1);

              close(fd);

              return 0;
      }

        本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
        轉(zhuǎn)藏 分享 獻花(0

        0條評論

        發(fā)表

        請遵守用戶 評論公約

        類似文章 更多