Ah thank you all very much for your help. Following your advice I was able to fix it perfectly! Here is what I have now:
Code:
//i have a variable size which is an int and is the byte size of the file
//i got the byte size of file from stat
int fileread = open("original.txt", O_RDONLY);
void *buffer;
buffer = malloc(sizeof(void) * size);
int nread = read(fileread,buffer,size);
int filewrite = open("original.txt.backup",O_CREAT | O_RDWR, 0644);
write(filewrite,buffer,size);
close(filewrite);
close(fileread);
0644 for rw-r--r--
Thanks!
Bookmarks