Linux下C语言复制文件

Linux下C语言复制文件,第1张

概述从usr/bin/info复制到myinfo.c #include<unistd.h>#include<fcntl.h>#include<sys/types.h>#include<sys/stat.h>#include<stdio.h>int main(){ const char* pathName="myinfo.c"; int in,out,flag

从usr/bin/info复制到myinfo.c

#include<unistd.h>#include<fcntl.h>#include<sys/types.h>#include<sys/stat.h>#include<stdio.h>int main(){    const char* pathname="myinfo.c";    int in,out,flag;    char buffer[10240];    in=open("//usr//bin//info",O_RDONLY,S_IRUSR);    if(in==-1)    {        printf(" 打开文件info失败 !\n");        return -1;    }    out=creat(pathname,S_IWUSR);    if(in==-1)    {        printf("创建文件myinfo失败!\n");        return -1;    }    while((flag=read(in,buffer,10240))>0)    {        write(out,flag);    }    close(in);    close(out);    printf("复制文件info到myinfo完成!\n");    return 0;}
总结

以上是内存溢出为你收集整理的Linux下C语言复制文件全部内容,希望文章能够帮你解决Linux下C语言复制文件所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/yw/1023926.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-23
下一篇 2022-05-23

发表评论

登录后才能评论

评论列表(0条)

保存