I'm using Unix, trying to do this networking assignment in C.
how do you create a file and copy it to another existing file?
You open the source file using fopen("infile","rb") and the destination
After the two successful opens you read the source file using getc and
write the destination file using putc until EOF comes.
Finally you close the files.
Well, this was a bit longer than writing the program, but this being a
class assignment (as it should be) I wanted to leave some way for to think
on the solution and to learn from practice.
(BTW: "r" and "w" are sufficient on UNIX, but more portable regarding
Windows if you use "rb" and "wb" and does not harm UNIX)
[ back to toc ]