You are on page 1of 1

#include <stdio.

h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/file.h>
#include <sys/sendfile.h>
#include <sys/random.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/fcntl.h>
int main()
{
int fd;
int fOut , fIn;
char buffer[50];
static char message[] = "Hello world";

fd=open("LAB04_ONE.txt", O_CREAT|O_WRONLY, 0642);


printf("Writing Data to file using Write Command");
read(fd, buffer , sizeof(message));

write(fd, message, sizeof(message));


fIn = open("LAB04_ONE.txt", O_RDONLY);
fOut = open("LAB04_TWO.txt", O_RDONLY);
sendfile(fOut, fIn, 0, buffer);
close(fIn);
close(fOut);
printf("DONE\n");
}

You might also like