The first thing you need to do is find out why the call is failing. #include errno.h and string.h, and set errno = 0 before the call to open(). Then, if the open() fails, call something like printf("%s\n",strerror(errno));
You'll find a list of possible errors, and what they mean, in the man-page for open
Hope that's of some help,
— Robert J. Lee