Welcome 微信登录

首页 / 操作系统 / Linux / 在Linux下用C语言实现文件拷贝

/*
Function:copy file from file1 to file2
How to execute: ./copyfile file1 file2 (under Linux)
Data:2007-05-09
*/

#include /*fprintf(),stderr,BUFSIZ*/
#include /**/
#include /*stderror()*/
#include /*open(),flag*/
#include /*errno*/
#include /*ssize_t*/
#include
#include /*mode_t*/

#define BUFFER_SIZE 3

int main(int argc,char **argv)
{
int from_fd,to_fd;
int bytes_read,bytes_write;
char buffer[BUFFER_SIZE];
char *ptr;

if(argc!=3)
{
fprintf(stderr,"Usage:%s fromfile tofile a",argv[0]);
exit(1);
}