Firstly, to answer your question about the various arguments that can be
passed to open() , the flags argument that you refer to tells the system
what you intend to do with the open file (i.e. open for reading or
writing or both). You build this argument by or-ing together the various
'O' flags, re-read the man pages for a description of the various 'O'
flags. Tech docs can be rather terse but you need to get used to them.
As for the rest I'm not quite sure what you mean when you say:
"...but I just kept getting back that they weren't recognized when I
compiled the program."
Are you getting a compile time error? A runtime error? It's unclear. By
the way there is a book called "Advanced Programming in the UNIX
Environment" by Richard Stevens that describes many of these system calls
in depth with examples of their use...
Dave
> Hi, I'm trying to use open and read to open a file and read it's
> contents. The file will contain a bunch of characters. All I want to
> do is open it, read all the characters and find out how many bytes
> there were in the file, actually seeing the characters isn't important
> to me. But I can't get it to work, I'll show you what I did.
> char buffer[buff_size];
> int n, val = 1;
> n = open( "filename.dat", val);
> read( n, &buffer, sizeof( char) );
> ok, this is a stripped down version, and I've tried it several ways,
> but no luck. as for open, I'm not to sure what exactly to put for the
> flag, the man command in unix game me a bunch of words, but I just
> kept getting back that they weren't recognized when I compiled the
> program.
> Thanks for any help, and yes, I am pretty new to C.
> Ford