473,403 Members | 2,270 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

the difeirent bettwen the function open() with two an three parameters

hi all, i dont dont whats the difference, and the different bettwen flags
and mode
Sep 28 '06 #1
7 2412
"freegnu" <fr*****@163.comwrites:
hi all, i dont dont whats the difference, and the different bettwen flags
and mode
Please include your question in the body of your article. Not everyone
can easily see the subject header.

The question was: "the difeirent bettwen the function open() with two
an three parameters".

The open() function is not part of standard C. You're probably
referring to the POSIX function by that name. If so,
comp.unix.programmer would be an appropriate newsgroup for your
question. (That's assuming that reading your system's documentation
("man open" or "man 2 open") doesn't answer it for you.)

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Sep 28 '06 #2

freegnu wrote:
hi all, i dont dont whats the difference, and the different bettwen flags
and mode
The third parameter in open is to give mode while we create a file
using open system call, where flag 'll be O_CREAT and we can specify
the user access permissions using mode.
ex: open(char filename, O_CREAT, S_IRUSER);

If the file is already there, no need of third parameter.

flag is to give type of access of file and mode to specify who can
access the files.

Sep 28 '06 #3
deepak wrote:
freegnu wrote:
>hi all, i dont dont whats the difference, and the different bettwen flags
and mode

The third parameter in open is to give mode while we create a file
using open system call, where flag 'll be O_CREAT and we can specify
the user access permissions using mode.
ex: open(char filename, O_CREAT, S_IRUSER);

If the file is already there, no need of third parameter.
Just to be clear, it is needed when you use the O_CREAT
flag, wether the file already exists or not :-)
Sep 28 '06 #4
=?ISO-8859-1?Q?=22Nils_O=2E_Sel=E5sdal=22?= <NO*@Utel.nowrote:
deepak wrote:
freegnu wrote:
hi all, i dont dont whats the difference, and the different bettwen flags
and mode
The third parameter in open is to give mode while we create a file
using open system call, where flag 'll be O_CREAT and we can specify
the user access permissions using mode.
ex: open(char filename, O_CREAT, S_IRUSER);

If the file is already there, no need of third parameter.

Just to be clear, it is needed when you use the O_CREAT
flag, wether the file already exists or not :-)
Just to be clearer, it may or may not be needed for any existing open()
function; ISO C does not define it, so in conforming mode, a compiler
must accept my declaration of a function open(struct list *head).

Just to be even clearer, if the function accepts both 2 or 3 arguments,
but is not a variadic function, it isn't C at all; not ISO C, not POSIX,
not any kind of C.

Richard
Oct 3 '06 #5
rl*@hoekstra-uitgeverij.nl (Richard Bos) writes:
[...]
Just to be clearer, it may or may not be needed for any existing open()
function; ISO C does not define it, so in conforming mode, a compiler
must accept my declaration of a function open(struct list *head).

Just to be even clearer, if the function accepts both 2 or 3 arguments,
but is not a variadic function, it isn't C at all; not ISO C, not POSIX,
not any kind of C.
POSIX (or IEEE 1003.1, or whatever) declares it as:

int open(const char *path, int oflag, ... );

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Oct 3 '06 #6
Keith Thompson <ks***@mib.orgwrote:
rl*@hoekstra-uitgeverij.nl (Richard Bos) writes:
[...]
Just to be clearer, it may or may not be needed for any existing open()
function; ISO C does not define it, so in conforming mode, a compiler
must accept my declaration of a function open(struct list *head).

Just to be even clearer, if the function accepts both 2 or 3 arguments,
but is not a variadic function, it isn't C at all; not ISO C, not POSIX,
not any kind of C.

POSIX (or IEEE 1003.1, or whatever) declares it as:

int open(const char *path, int oflag, ... );
A creative use of variadic functions, that, but I wouldn't recommend it.

Richard
Oct 3 '06 #7
Richard Bos wrote:
A creative use of variadic functions, that, but I wouldn't recommend it.

Richard
Interesting, I didn't know that POSIX open() was variadic. That being said, I
don't think I can remember myself using it in a variadic fashion.
Oct 3 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Birgit Rahm | last post by:
Hallo Newsgroup, I have the following problem: I work with Python 2.2 and invoke functions via CORBA ( I use onmiORB/omniORBpy) on a server. The server provides me a function, where the 3...
3
by: Bryan Parkoff | last post by:
Do C/C++ Compiler allow function to contain more than 8 parameters? I checked MS Visual C++ 6.0 that it can only limit 8 parameters, but most C/C++ Compiler can limit maximum 256 parameters. Can...
64
by: Morgan Cheng | last post by:
Hi All, I was taught that argument valuse is not supposed to be changed in function body. Say, below code is not good. void foo1(int x) { x ++; printf("x+1 = %d\n", x); } It should be...
3
by: jimb | last post by:
I'm just starting to learn asp.net. What I have is a registration form for a message board system. Basically, the user enters in their info and it's validated. So I have a custom validator check...
2
by: Maxwell_Smart | last post by:
Is there a way for a function to refer to itself generically? I'd like to use such a thing (should it exist) for convenience and consistency, not functionality. For example: Function...
3
by: Beta What | last post by:
Hello, I have a question about casting a function pointer. Say I want to make a generic module (say some ADT implementation) that requires a function pointer from the 'actual/other modules'...
15
by: marydeepthy | last post by:
Hi, I would like to know what happens internally when a c programme is executed. LIke, when we call a function, all the previous values will be pushed on to stack and the local variables of...
10
by: Matthew Wilson | last post by:
Lately, I've been writing functions like this: def f(a, b): assert a in assert b in The point is that I'm checking the type and the values of the parameters.
5
by: mnarewec | last post by:
Hi folks, I want to create a procedure where by it will take a sqlcommand, a string, and property. I want to use this procedure to add parameters to my sql command of type stored procedures since I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.