[LCP]creating files with open()
Bill Rausch
bill at numerical.com
Tue Oct 9 02:13:15 UTC 2001
At 5:52 PM +0930 10/8/01, Andy Zivkovic wrote:
>Sorry for not replying earlier, I've been so busy doing work I forgot to
>reply :(
>
>Madhav M. was correct, I forgot to specify O_WRONLY. When I did that,
>everything started to work. I was so busy trying to do the UDP/transfer
>protocol stuff that I forgot the basics of file I/O. :(
> file = open("file.txt", O_CREAT|O_EXCL);
If all you did was add O_WRONLY then the program is still incorrect.
It may work on your particular box, but if you specify O_CREAT you
also need to specify the "mode" as the third argument to open()
according to the man page.
> O_CREAT ...
> The file access permission bits of the new file
> mode are set to the value of mode, ...
--
Bill Rausch, Software Development, Unix, Mac, Windows
Numerical Applications, Inc. 509-943-0861 bill at numerical.com
More information about the linuxCprogramming
mailing list