首页 > 其他分享 >代码

代码

时间:2022-09-22 09:33:26浏览次数:50  
标签:fr int 代码 fp1 fp2 include buf

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

int main()
{
        int fp2 = open("file2", O_RDWR | O_CREAT,0777);
        if(fp2 == -1)
        {
                perror("tips:");

        }
        printf("fp2 = %d\n",fp2);
        int fp1 = open("1.sh",O_RDWR,0777);
        if(fp1 == -1)
        {
                perror("tips:");
                exit(1);
        }
        printf("fp1 = %d\n",fp1);

        char buf[2048] = {110};
        int fr = read(fp1,buf,sizeof(buf));
        if(fr == -1)
        {
                perror("tips:");
                exit(1);
        }
        while(fr)
        {
                int fw = write(fp2,buf,fr);
                printf("fw = %d\n",fw);
                fr =read(fp1,buf,sizeof(buf));
        }
        int fc1 = close(fp1);
        int fc2 = close(fp2);
        printf("fc1 = %d,fc2 = %d\n",fc1,fc2);

}```

标签:fr,int,代码,fp1,fp2,include,buf
From: https://www.cnblogs.com/yu15141310373/p/16718025.html

相关文章