copy.c

来自「C语言复制功能程序的源码」· C语言 代码 · 共 46 行

C
46
字号
/这是C语言复制程序的源码,是提升C语言项目工作能力的好方法/
#include <stdio.h>#include <stdlib.h>#include <fcntl.h>#include <sys/types.h>#include <sys/stat.h>#define MAXSIZE 1024char buf[MAXSIZE];int main(int argc, char *argv[]){	int fdest;	int fd;	int rep;	int file;	if (argc != 3)		{			printf("the")		}	fd = open(argv[2],O_RDONLY);	if ((fd < 0 || fd == 0))	{		printf("open error or open empty\n");		exit (1);	}	rep = read(fd, buf, 50);	if ((rep < 0) || (rep == 0))	{	printf("read error or read empty\n");		exit (1);	}	fdest = open (argv[1], O_CREAT | O_WRONLY);	if ((fdest < 0) || (fdest == 0))	{			printf("the file is not exist\n");		exit (1);	}		file = write (fdest, buf, 50);	if ((file < 0))	{	printf("operate is not sucess\n");		exit (1);	}	printf("%s\n",buf);}

⌨️ 快捷键说明

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