Hi all,
why does C language permits an extra comma in initializer list
ex:- int days[] = {
31,28.31,30,31, 30,
31,31,30,31,30, 31,
}
i have heard it is for the purpose of automatic code generation
is there any other purpose than this, if so why ...????
Feb 16 '08
22 3602
On Feb 16, 5:38 pm, Ben Pfaff <b...@cs.stanfo rd.eduwrote:
Observe:
int array[] = {
#ifdef ELEMENT_ONE
1,
#endif
<snip>
};
versus:
int array[] = {
#ifdef ELEMENT_ONE
1
# if (defined(ELEMEN T_TWO) || defined(ELEMENT _THREE) \
|| defined(ELEMENT _FOUR))
,
# endif
#endif
<snip>
};
I know which one I would prefer to maintain.
I can't think of too many cases where it is problematic to do:
int array[] = {
#ifdef ELEMENT_ONE
1,
#endif
SENTINEL
};
to force the existence of at least one fixed
element.
Harald van Dijk wrote:
int foo[] = {
#ifdef FOO
42, 0,
#endif
37, EOF
#ifdef BAR
,'\n', EXIT_FAILURE
#endif
#ifdef BAZ
,SEEK_END, ERANGE
#endif
}
It's not difficult when you have at least one fixed item in the list.
But it is so ugly! :-)
--
Army1987 (Replace "NOSPAM" with "email")
On Feb 16, 10:33 pm, Richard Heathfield <r...@see.sig.i nvalidwrote:
vipps...@gmail. com said:
On Feb 16, 7:14 pm, Richard Heathfield <r...@see.sig.i nvalidwrote:
aark...@gmail.c om said:
Hi all,
why does C language permits an extra comma in initializer list
ex:- int days[] = {
31,28.31,30,31, 30,
Between 31 and 28 you meant ,, not ..
How do you know?
Call me psychic if you like.
28.31 is a valid value for initializing in integer
context.
Yes, but on this occasion it was not what was intended.
Yeah richard is correct he is indeed psychic to a certain extent
I did n't mean 28.31 , i meant 28,31 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Alberto Vera |
last post by:
Hello:
I have the next structure:
How Can I make it using Python?
How Can I update the value of 6?
|
by: Arne |
last post by:
From: "Arne de Booij" <a_de_booij@hotmail.com>
Subject: Comma delimited array into DB problems
Date: 9. februar 2004 10:39
Hi,
I have an asp page that takes input from a form on the previous page,
puts that into an array and inserts the array into SQL server.
Now here is the problem:
|
by: Shawn Odekirk |
last post by:
Some code I have inherited contains a macro like the following:
#define setState(state, newstate) \
(state >= newstate) ? \
(fprintf(stderr, "Illegal state\n"), TRUE) : \
(state = newstate, FALSE)
This macro is called like this:
setState(state, ST_Used);
|
by: siliconwafer |
last post by:
Hi,
In case of following expression:
c = a && --b;
if a is 0,b is not evaluated and c directly becomes 0.
Does this mean that && operator is given a higher precedence over
'--'operator?
as opposed to what is mentioned in precedence table?
Also,
with comma operator.
consider,
|
by: Sriram Rajagopalan |
last post by:
Hi,
Is the extra comma at the end of an enumerator-list valid according to
the C standards?
With the gcc compiler the following is valid:
enum DAYS {MONDAY, TUESDAY, }day1;
gcc does not even *warn* about the extra comma after "TUESDAY".
| |
by: Wayne |
last post by:
I have the following string:
"smith", "Joe", "West Palm Beach, Fl."
I need to split this string based on the commas, but as you see the city
state contains a comma. String.split will spilt the city state. Is there a
built in function that I'm missing that will do the split and recognize that
the comma in city state is part of the item?
--
|
by: Benjamin Rutt |
last post by:
There has been a problem that has been bugging me for a while for
reading input from standard in. Consider the following simple program:
#!/usr/bin/env python
import sys
print 'enter something: ',
answer = sys.stdin.readline().strip()
print 'you answered {%s}' % (answer)
When I run this interactively, the following happens:
|
by: alf |
last post by:
Hi,
I can not find out where the extra space comes from. Run following:
import os,sys
while 1:
print 'Question ]?',
if sys.stdin.readline().strip() in ('Y','y'):
#do something
pass
|
by: Lighter |
last post by:
In 5.3.3.4 of the standard, the standard provides that "The lvalue-to-
rvalue(4.1), array-to-pointer(4.2),and function-to-pointer(4.3)
standard conversions are not applied to the operand of sizeof."
I think this rule is easy to understand. Because I can find the
contexts of applying the rule as follows.
(1)
int* p = 0;
int b1 = sizeof(*p); // OK, b1 = 4, *p would not be evaluated.
|
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...
|
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...
| |
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,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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 we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |