/*
*FileCopy.c - 文件内容拷贝
*writed by cn_shift
*2006.4.1
*/
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#define BUFFERSIZE 1
main()
{
int in,out,n;
char buffer[BUFFERSIZE];
in=open("./file1",O_RDONLY);
if(in<0)
{
printf("Open errir!\n");
exit(-1);
}
out=open("./file2",O_WRONLY | O_CREAT);
if(out<0)
{
printf("Open error!\n");
exit(-1);
}
while((n=read(in,buffer,BUFFERSIZE))>0)
{
write(out,buffer,BUFFERSIZE);
}
close(in);
close(out);
}
*FileCopy.c - 文件内容拷贝
*writed by cn_shift
*2006.4.1
*/
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#define BUFFERSIZE 1
main()
{
int in,out,n;
char buffer[BUFFERSIZE];
in=open("./file1",O_RDONLY);
if(in<0)
{
printf("Open errir!\n");
exit(-1);
}
out=open("./file2",O_WRONLY | O_CREAT);
if(out<0)
{
printf("Open error!\n");
exit(-1);
}
while((n=read(in,buffer,BUFFERSIZE))>0)
{
write(out,buffer,BUFFERSIZE);
}
close(in);
close(out);
}