开发环境是fedora13,(现在已经出到16了都)。vim编辑器+gcc,g++编译器。
#include<stdio.h>
#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<unistd.h>
int main(int argc,char *argv[])
{
if(argc!=3)
printf("It's error\n");
int s,d,c;
char buf[1024];
s=open(*(argv+1),O_RDWR);
d=open(*(argv+2),O_RDWR|O_CREAT);
while((c=read(s,buf,1024))>0)
write(d,buf,c);
close(s);
close(d);
return 1;
}
第一个参数为源文件,第二个为目的文件。