⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 fcopy.c

📁 嵌入式Linux程序设计与应用案例 电子书源码 中国电力出版社
💻 C
字号:
/*************//name :fcopy.c//author : pyy//date : 2007-10-22***************/#include<unistd.h>#include<sys/types.h>#include<sys/stat.h>#include<fcntl.h>#include<stdlib.h>#include<stdio.h>int main(){    int  fdsrc, fddes, nbytes;    int  flags=O_CREAT | O_TRUNC | O_WRONLY;    int  z;    char buf[20],mysrc[20],mydes[20];    printf(" input your source file: ");    scanf("%s",mysrc);    printf(" input your target file:");    scanf("%s",mydes);    fdsrc = open(mysrc , O_RDONLY);    if (fdsrc <0 )    {        perror("write des file");        exit(1);    }    fddes = open(mydes, flags, 0644);    if( fddes<0 )    {        perror("open des file"); exit(1);    }    while( ( nbytes = read(fdsrc,buf,20))>0 )    {        z = write(fddes,buf,nbytes);        if( z < 0)        {            perror("write des file.");        }     }  /* while  */    close(fdsrc);    close(fddes);    exit(0);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -