|
/*this is a example of copy*/
#include <sys/types.h>
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
main ()
{
int a, b;
char c[20];
char d[20];
char buf[1024];
printf ("input file name of source:");
scanf ("%s", c);
printf ("input file name of destination:");
scanf ("%s", d);
a = open (c, O_RDWR);
read (a, buf, 1024);
close (a);
printf ("%s", buf); /*test buf*/
creat (buf, S_IRUSR | S_IWUSR);
b = open (d, O_RDWR);
write (b, buf, strlen (buf));
close (b);
}
我的意思是文件复制,但总得到一个很怪的文件,如我文件11中内容为123 erty,我想复制给12,但总得到名为123 etry???的文件。 |
|