Hi. i'm trying to copy a binary already with a predefined permissions. I got this code:
FILE *f1, *f2;
char cp;
f1 = fopen("file1","rb");
f2 = fopen("file2","wb");
while(!feof(f1)) {
cp = fgetc(f1);
if(!feof(f1)) fputc(cp, f2);
fclose(f1);
fclose(f2);
but this just copy a file. But what i'm trying to do is copy file for example with permissions 0777.
i saw somewhere that people using something like this:
f1=open("file1",O_RDONLY);
f2=open("file2",O_WRONLY|O_CREAT,0777);
i was trying many ways but always it copy a binary into another which is just empty file. Plz help