SOGO論壇
  登入   註冊   找回密碼
查看: 563|回覆: 0
列印 上一主題 下一主題

[技術文章] 檔案開啟 [複製連結]

Rank: 11Rank: 11Rank: 11Rank: 11

熱心參予論壇活動及用心回覆主題勳章 數位硬體勳章

狀態︰ 離線
跳轉到指定樓層
1
發表於 2012-7-18 11:31:51 |只看該作者 |倒序瀏覽
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#define size 512
int main(){
    char filename[20],copyfile[20];
    char buf [size];
    int fd1,fd2,fd3;
    //see if correct number of command line arguments
    printf("please input filename:\n");
    scanf("%s",filename);
    if ((fd1= open(filename,O_RDONLY)) == -1) {
        printf("cannot open file.");
        exit(1);
    }
    printf("please input copyfile:\n");
    scanf("%s",copyfile);
    fd3=open(copyfile,O_CREAT|O_WRONLY,0644);
    while ((fd2=read(fd1,buf,size))>0){
        write(fd3,buf,fd2);
    }
    close(fd1);
    close(fd3);
}
喜歡嗎?分享這篇文章給親朋好友︰
               感謝作者     

請注意︰利用多帳號發表自問自答的業配文置入性行銷廣告者,將直接禁訪或刪除帳號及全部文章!
您需要登錄後才可以回覆 登入 | 註冊


本論壇為非營利自由討論平台,所有個人言論不代表本站立場。文章內容如有涉及侵權,請通知管理人員,將立即刪除相關文章資料。侵權申訴或移除要求:abuse@oursogo.com

GMT+8, 2024-4-28 06:39

© 2004-2024 SOGO論壇 OURSOGO.COM
回頂部