title: Keeping fileowner and permissions after copying file in C
body: <p>here is my problem: In C, I create the copy of a file (with some changes) This is done trivially via fopen(), getchar and putchar.
  Copying the file is fine and the outputfile itself is what I want it to be.</p>
  
  <p>My problem is: I assume that I will use this program often as sudo and then the resulting file has both another owner (root) as well as different permissions (execute rights are gone).</p>
  
  <p>My question is: How can I copy the owner and permissions of the original file and then write them into the new one?</p>