473,654 Members | 3,060 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2430
"freegnu" <fr*****@163.co mwrites:
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.progr ammer 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_Keit h) 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=2 E_Sel=E5sdal=22 ?= <NO*@Utel.nowro te:
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_Keit h) 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.orgw rote:
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
4538
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 arguments are out-arguments and the return is void / None. How can I get these out arguments? I have read that every argument is seen as local to the function and can not be used as return value.
3
1664
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 you please verify for me? Usually, I write function that is about 100 lines. I would need 20 parameters which they are all reference to global variable inside struct. For best optimization, it does not require to create stack frame because...
64
3370
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 "refactor-ed" to be
3
1384
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 to make sure the username is unique, I have another custom validator that makes sure the email address is unique and then I save the info to the database. That means I open the connection to the sqlserver 3 times. Seems inefficient to me. Is...
2
1754
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 Common(Some_String as String) As String ... End Function
3
3644
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' that takes arguments of type (void *) because the ADT must be able to deal with any type of data. In my actual code, I will code the function to take arguments of their real types, then when I pass this pointer through an interface function, I...
15
4975
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 that particular function will be pushed in to the stack. when the function returns, all the local variables will be poped out.. like this, what happens when we call a strcpy function. what happens in
10
3132
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
19126
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 have a lot parameters to pass into the store procedure. Here is current my procedure to call store procedure to insert a record: Public Function AddPreviousAddress() As Integer Try cnnCPSS.Open()
0
8294
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8816
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8709
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8494
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8596
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6162
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4297
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1924
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1597
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.