473,473 Members | 1,843 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Complex statement

Hi all,

Can somebody explain what this statement does,
if ((tempFD = open(tempFileName, O_RDWR | O_CREAT | O_EXCL)) < 0)

Thanks in advance
Seema

Nov 15 '05 #1
6 5528

se********@yahoo.co.in wrote:
Hi all,

Can somebody explain what this statement does,
if ((tempFD = open(tempFileName, O_RDWR | O_CREAT | O_EXCL)) < 0)

Thanks in advance
Seema


tempFD = open(tempFileName, O_RDWR | O_CREAT | O_EXCL);
if (tempFD < 0)

Do "man open" to see open's input parameters and return value.

Nov 15 '05 #2
se********@yahoo.co.in wrote:
Hi all,

Can somebody explain what this statement does,
if ((tempFD = open(tempFileName, O_RDWR | O_CREAT | O_EXCL)) < 0)


If we knew for sure what version of what library you were using, some
might. But they shouldn't, since the experts for your platform or
implementation have newsgroups of their own. Unless your question is
about C as defined by the standard, no reliable substantive answers from
comp.lang.c should be expected. In your case, the function open() is
not defined as part of the standard C libaries (nor are O_RDWR, O_CREAT,
or O_EXCL). Questions about fopen(), a standard C function, we can
answer. It is most likely (although definitely not certain) that one of
the unix programming newsgroups is what you want.
Nov 15 '05 #3

se********@yahoo.co.in wrote:
Hi all,

Can somebody explain what this statement does,
if ((tempFD = open(tempFileName, O_RDWR | O_CREAT | O_EXCL)) < 0)

Thanks in advance
Seema


The open() function itself is not part of the standard C library, but
part of the Unix (POSIX?) API. Refer to the man page for specifics.
The above is a shorthand equivalent to the following:

char *tempFileName = ...; /* some file name */
int fileAccessMask = 0_RDWR | O_CREAT | O_EXCL;
int tempFD = open (tempFileName, fileAccessMask);

if (tempFD < 0)
{
/* do something */
}

Essentially, the open() call and the test are being squashed into the
conditional expression.

Nov 15 '05 #4
John Bode wrote:
se********@yahoo.co.in wrote:
Hi all,

Can somebody explain what this statement does,
if ((tempFD = open(tempFileName, O_RDWR | O_CREAT | O_EXCL)) < 0)

Thanks in advance
Seema


The open() function itself is not part of the standard C library, but
part of the Unix (POSIX?) API. Refer to the man page for specifics.
The above is a shorthand equivalent to the following:

char *tempFileName = ...; /* some file name */
int fileAccessMask = 0_RDWR | O_CREAT | O_EXCL;
int tempFD = open (tempFileName, fileAccessMask);


OT, but you should never call open with O_CREAT and no mode.

Nov 15 '05 #5
In article <11*********************@z14g2000cwz.googlegroups. com>,
John Bode <jo*******@my-deja.com> wrote:

char *tempFileName = ...; /* some file name */
int fileAccessMask = 0_RDWR | O_CREAT | O_EXCL;


gcc says: invalid suffix "_RDWR" on integer constant
Nov 15 '05 #6
seema_c...@yahoo.co.in wrote:
Can somebody explain what this statement does,
if ((tempFD = open(tempFileName, O_RDWR | O_CREAT | O_EXCL)) < 0)


open() is not a standard C function, it belongs to UNIX.
if calling open() failed, it will return -1.
therfore, the expression " (tempFD = open(tempFileName, O_RDWR |
O_CREAT | O_EXCL)) < 0" is to check whether the call is successful or
not.

Nov 15 '05 #7

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

Similar topics

3
by: Marcus | last post by:
Hi I have a very complex sql query and a explain plan. I found there is a full table scan in ID=9 9 8 TABLE ACCESS (FULL) OF 'F_LOTTXNHIST' (Cost=84573 Card=185892...
8
by: J.Haan | last post by:
Hi all. I'm currently coping with a problem on which I hope you could shed some light. Imagine the following: I have table in DB2 8.1 (.5) which is defined as: table test { t1 smallint,...
6
by: Hardy | last post by:
One of my customers have a sql statement totaled more than 400 lines, about 40KB. when excuted, error arrised saying "SQL0101N The statement is too long or too complex". I tried one of his...
3
by: Susie Swint | last post by:
I have the following IIf statement which worked in Access 95 but will not work in Access 2002. The error message I get is that the expression is typed incorrectly, or is too complex to be...
3
by: Kevin Rollo | last post by:
I'm playing with a generic routine to export data, the concept is to have a list of data driven templates defining what fields to output. Evaluating a simple variable field name in the function...
2
by: Ben de Vette | last post by:
Hi, I'm using the querybuilder when updating a record in a table (Access). However, I get a "Query is too complex" message. The Primary key is autonumbered. Why is it making such a complex...
6
by: Jon Bilbao | last post by:
I´m trying a select clause in two steps because it´s too complex. First: SELECT Reference, Results.idEnsayo, Results.Num_taladro, min(Results.dTime) + 500 AS tIni, max(Results.dTime) - 500 AS...
1
by: Randy Volkart | last post by:
I'm trying to fix a glitch in a complex access database, and have a fairly complex problem... unless there's some obscure easy fix I don't know being fairly new with Access. Basically, the area...
1
by: Rahul Babbar | last post by:
Hi, I ran the scripts in a file from Command Line Processor and it gave the error for all the constraints being added, but not the indexes being added. For a simple statement like Alter...
3
by: Eric Davidson | last post by:
DB2 9.5 I keep geting the message. SQL0101N The statement is too long or too complex. SQLSTATE=54001 When one of my sql statements takes over 60 seconds to compile the sql statement. Is...
0
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...
0
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,...
0
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...
1
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...
1
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
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...

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.