Linux系统调用和库函数

时间:2022-02-15 22:34:58
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
using namespace std; void copy(char *a, char *b); void copy(char *a, char *b)
{
int fds, fdd;
char buf[ * ]; size_t hasread = ;
fds = open(a, O_RDONLY);
fdd = open(b, O_WRONLY, O_CREAT);
if (fds && fdd)
{
while ((hasread = read(fds, buf, sizeof(buf))) > )
{
write(fdd, buf, hasread);
cout << buf << endl;
}
close(fds);
close(fdd);
}
} int main()
{
char a[];
char b[]; scanf("%s", a);
scanf("%s", b); copy(a, b); return ;
}