[LCP]creating files with open()

Bill Rausch bill at numerical.com
Tue Oct 2 01:54:08 UTC 2001


At 7:47 PM +0930 9/29/01, Andy Zivkovic wrote:
>Hi,
>
>I'm trying to open/create a file if it doesn't exist, then write to it,
>however writes are failing. Additionally, the permissions on the file is
>really strange. On linux (home) and windows (home) the function I've copied
>below creates the file, but the write fails, and the close succeeds. On
>Solaris (uni) the open fails.
>
>Is there anything immediately obvious with my program?
>
>   file = open("file.txt", O_CREAT|O_EXCL);

You need the third parameter on the open call when creating a new file.

>
>

-- 
  Bill Rausch, Software Development, Unix, Mac, Windows
  Numerical Applications, Inc.  509-943-0861   bill at numerical.com



More information about the linuxCprogramming mailing list