so , should'nt it return -1 once it reaches the EOF and tries to read the next byte?
so , does it mean that even after the EOF is reached and it tries to read the next byte, it continues to "read" from the "stream"? eventhough there is nothing to read?
i guess i misunderstood this...
thanks,problem solved
ok, i have another doubt on open()
i change my c-code
from
sourcefile=open(argv[1],O_RDONLY);
to
sourcefile=open(argv[1],O_RDONLY,0664);
shouldn't open() be able to override the default permissions already set?
i tried and apparently it does not. is there any reason, besides enforcing security(that the only thing that i could think of)? and is there any way around this? (besides giving the file permissions using the system("chmod "); function?)
The third option to open() - which is shown in man pages as "..." is only used when a new file is being created. In your case you are opening an existing file as read only.
"..." is a way of saying that the number and types of the remaining arguments may vary. There may be none or there may be one or more.
That's not the preferred way to specify file modes in UNIX. By not giving it the O_CREAT file it means that the file exists and the open call will have no affect on it and instead of giving 0644 for the file mode bits use...