Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
Maybe I'm missing something, but why are you not specifying the O_BINARY flag?
Mainframe assembler programmer by trade. C coder when I can.
Thanks for all the help
I tried using O_BINARY flag but it gives an error.I guess open() opens a file directly in binary mode.
These are my open() calls for the source and destination :
Code:fps=open(source,O_RDONLY); fpd=open(dest,O_WRONLY|O_CREAT,0777);
There is no such thing as O_BINARY in Linux, as far as I can tell. It should certainly not make any difference, as line-endings in Linux are the same in C and in the actual files.
--
Mats
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
I see, now that I've pulled out my Advanced Programming in the Unix Environment. (I was reading my Encyclopedia C, circa '91, that has a strong bent towards DOS).
APUE says to use fread() and fwrite() for binary IO.
Todd
Mainframe assembler programmer by trade. C coder when I can.
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
Well, there's obviously something different about the two sets of functions, or else there wouldn't be two sets.
Mainframe assembler programmer by trade. C coder when I can.
read() and write() are operating system API calls, in other words the most basic level of I/O you can do on UNIX. fread() and fwrite() are standard functions which in all likelihood are built on top of read() and write().
You're looking at two layers, not two totally different sets of functions.
> This is the code I have written for copying files from source to destination:
Great, and right after I told you to use the return results, you post something which ignores them.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
Ah, I see. Thanks.
Mainframe assembler programmer by trade. C coder when I can.