总结从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语言复制文件所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)