i am trying to copy to a file the contents of two input files in c with the help of read, write and open. At first i tried to simply copy the contents of only one file that contains the 'hello' world, but this is what gets written: "hello h«Ú^?^@^@^A^@^@^@^@^@^@^@m G«Ú^?^@^@^@^@^@^@^@^@^@^@^Pjh«Ú^?^@^@^A^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^A^@^@^@þ^?^@^@°<91>h«Ú^?^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^H<95>h«Ú^?^@^@P)»Ó " my code is:
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
int main(int argc , char *argv[]){
int fd1,fd2,fdout;
int fread1, fread2;
char buff[128];
int fconf(int f1, int f3){
fd1 = open(argv[1],O_RDONLY);
fdout = open(argv[2],O_RDONLY | O_CREAT | O_APPEND | O_RDWR);
fread1 = read(fd1,buff,sizeof(buff));
write(fdout,buff,sizeof(buff));
close(fd1);
close(fdout);
return 0;
}
}
I have no idea why this happens.