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);

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:


i was trying many ways but always it copy a binary into another which is just empty file. Plz help

The open flags do not set the file permissions -- they are two completly different things. After copying the file you have to change the permissions. Here's how to do it.

See here for information on the permissions

always it copy a binary into another which is just empty file

You might post this code that always produces empty copies so we can see what goes wrong.

thank you for your replies, but i have to deal with it later because now i have devastating exams and absolutely now free time for programming ;(