Hello
I was not able to find answers to there Qs on google or in the FAQ, so
here goes
Q1:
I refer to the question 2.10 in the FAQ
the following code compiled with gcc
(struct {int a; char* b; int c;}){1, "1", 'A'}.c
but is it valid ansi c?
Q2:
Are these equivalent?
(long)1 contra 1L
Q3:
I know of the following "constant classifiers" i.e. 1L
l and L, f and F, u and U
but are there more?
Thank you! 2 1046
In message <nT******************@news4.e.nsc.no>
Martin Johansen <mf**@online.no> wrote: Hello
I was not able to find answers to there Qs on google or in the FAQ, so here goes
Q1: I refer to the question 2.10 in the FAQ the following code compiled with gcc (struct {int a; char* b; int c;}){1, "1", 'A'}.c but is it valid ansi c?
It's valid in ISO C99, but not earlier versions.
Q2: Are these equivalent? (long)1 contra 1L
Yes, for that specific example, barring syntax quirks (eg "sizeof (long)1"
will be parsed differently from "sizeof 1L").
This might not be:
(long)1000000000000 vs 1000000000000L
because the suffix only specifies a minimum size, and it will grow to
long long if necessary. The first form would truncate it back down to long,
even if it didn't fit.
Q3: I know of the following "constant classifiers" i.e. 1L l and L, f and F, u and U but are there more?
C99 has "ll" or "LL" for long long.
--
Kevin Bracey, Principal Software Engineer
Tematic Ltd Tel: +44 (0) 1223 503464
182-190 Newmarket Road Fax: +44 (0) 1728 727430
Cambridge, CB5 8HE, United Kingdom WWW: http://www.tematic.com/
Martin Johansen <mf**@online.no> writes: Q1: I refer to the question 2.10 in the FAQ the following code compiled with gcc (struct {int a; char* b; int c;}){1, "1", 'A'}.c but is it valid ansi c?
This is called a compound literal; it is valid according to the current
ISO C standard (C99). Note, however, that most compilers do not yet
implement C99, but C89, the previous C standard. (GCC implements C99
only partially.)
Q2: Are these equivalent? (long)1 contra 1L
Yes.
Q3: I know of the following "constant classifiers" i.e. 1L l and L, f and F, u and U but are there more?
For integers, there are the suffixes L (long), U (unsigned), and UL
(unsigned long), and in C99 LL (long long) and ULL (unsigned long long).
For floating-point numbers, there are F (float) and L (long double). All
suffixes can be spelled in uppercase or lowercase letters.
Martin
--
,--. Martin Dickopp, Dresden, Germany ,= ,-_-. =.
/ ,- ) http://www.zero-based.org/ ((_/)o o(\_))
\ `-' `-'(. .)`-'
`-. Debian, a variant of the GNU operating system. \_/ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: drs |
last post by:
I just upgraded my Python install, and for the first time have True and
False rather than 1 and 0. I was playing around at the command line to test
how they work (for instance, "if 9:" and "if...
|
by: DevarajA |
last post by:
I've read that 0 is the 'null pointer constant', and assigning it to a
pointer makes it a 'null pointer'. Is that true? And is the opposite
true? (assigning a null pointer to an int sets the int to...
|
by: David W. Fenton |
last post by:
Today I was working on a hideous old app that I created a long time
ago that does a lot of showing/hiding/resizing of fields on one of
the forms. I had used constants to store reference values for...
|
by: ROSY |
last post by:
hello,
response if u ,on all level of questions:::
1.how a self deletable .exe file deleted on some future date & time
without
invoking the .exe itself?
2.if we want that any wildcard...
|
by: Jatinder |
last post by:
I 'm a professional looking for the job.In interview these questions
were asked with some others which I answered.But some of them left
unanswered.Plz help.
Here are some questions on C/C++, OS...
|
by: blangela |
last post by:
I have a former student who came to me and asked if I had any idea the
types of C++ questions that EA asks potential new hires to evaluate
their C++ knowledge/skills. I do not, but I thought...
|
by: shamirza |
last post by:
Question
Do ActiveX DLLs made in VB still need the VB runtimes on
the
machine?
________________________________________
Answer
In a word, Yes.
Visual Basic does not support what is known...
|
by: Leslie Sanford |
last post by:
I want to define a set of floating point constants using templates insteand
of macros. I'd like to determine whether these constants are floats or
doubles at compile time. In my header file, I have...
|
by: John Doe |
last post by:
Hi,
I am currently developping a software where items that will be inserted
into a graphical widget ListCtrl are first defined in static array as
shown below :
enum TUiContext
{...
|
by: shuisheng |
last post by:
Dear All,
I am always confused in using constants in multiple files.
For global constants, I got some clues from
http://msdn.microsoft.com/en-us/library/0d45ty2d(VS.80).aspx
So in header...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
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,...
| |