View Single Post
Old 10-25-2004, 04:15 PM   #2 (permalink)
joe_bruin
LOAD "*",8,1
 
Join Date: Feb 2003
Location: la.ca.us
Posts: 254
joe_bruin is on a distinguished road
Re: using correct path in open function

Quote:
Originally posted by mike_cana
Code:
  if (*acctFd = (fd = open(path, "O_CREAT", "r+")) < 0)
your second and third arguments to open(2) are garbage. O_CREAT is a defined value, not a string literal. include the following headers if you haven't done so already, and it will be defined for you.

Code:
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
the 3 argument version of open takes a numerical value which defines the mode bits of the file you want created. there are convenient defines for this one as well.

Code:
open(path, O_CREAT, S_IRUSR | S_IWUSR);
try "man 2 open" for more details.
joe_bruin is offline   Reply With Quote