initialization
Stephen Clamage
steve at taumet.com
Thu Aug 2 01:43:05 AEST 1990
rpjday at ccu.umanitoba.ca writes:
|int func(int a)
|{
| int i = a, j = i + 1 ;
|Am I allowed to initialize the integer "j" with the value of
|another variable initialized in the same line? What if I put
|the two definitions on separate lines?
According to ANSI C this is fine, and is equivalent in effect to
int i = a;
int j = i + 1 ;
(By "line" above, I assume you meant "declaration".)
The end of an initializer is a "sequence point", and must be fully
completed before the next initialization (or statement).
There may be non-standard compilers which do not follow this rule.
--
Steve Clamage, TauMetric Corp, steve at taumet.com
More information about the Comp.lang.c
mailing list