0

I am learning C, and:

I see a way to delete a file

remove (f_name);

a way to rename a file:

rename(old_f_name, new_f_name);

but I cannot find a way to copy a file. Can this be true?

copy(old_f_name, new_f_name);  //gives an error.

Must I write a routine to open the file, read through it's contents, and write it?

Thanks, Mark.

Cool Javelin
  • 776
  • 2
  • 10
  • 26
  • Search this site for **[c] copy file**. – Ken White Mar 22 '17 at 22:28
  • Also see [How can I copy a file on Unix using C?](http://stackoverflow.com/questions/2180079/how-can-i-copy-a-file-on-unix-using-c) – B. Wolf Mar 22 '17 at 22:46
  • So, what I am seeing is, removing and renaming files is easy, copying is hard. Geez, that seems like such a basic, necessary function that someone would have defined a standard for it by now. I get it is OS dependent, but come-on. – Cool Javelin Mar 23 '17 at 02:24
  • I'm sure that when you implement your very own `copy_file()` and account for all the possible permutations and bits (how to show a progress, what to do with data streams, how to handle removable storages, offline storages, permissions, going from one type of filesystem to another, etc, etc, etc) you'll change your tone – YePhIcK Mar 23 '17 at 04:28

0 Answers0