pardo@june.cs.washington.edu (David Keppel) (07/28/88)
I want to do something like:
enum zork_t { FOO, BAR, BAZ, ZORK, BORK, SPLODGE, SPLAT };
int a[6];
zork_t hoof;
a[FOO] = 23;
a[BAR] = 55;
for( hoof=BAZ; hoof<=SPLAT; ++hoof ){
a[hoof] = 0;
}
Question: which of these are legal under ANSI (proposed) C?
How about if I replace the "enum" line with "... FOO=0, ..."?
;-D on ( This could be worth a gross ) Pardo
pardo@cs.washington.edu
{rutgers,cornell,ucsd,ubc-cs,tektronix}!uw-beaver!june!pardo
henry@utzoo.uucp (Henry Spencer) (07/30/88)
In article <5390@june.cs.washington.edu> pardo@cs.washington.edu (David Keppel) writes: >I want to do something like: > > enum zork_t { FOO, BAR, BAZ, ZORK, BORK, SPLODGE, SPLAT }; > int a[6]; > zork_t hoof; > > a[FOO] = 23; > a[BAR] = 55; > for( hoof=BAZ; hoof<=SPLAT; ++hoof ){ > a[hoof] = 0; > } > >Question: which of these are legal under ANSI (proposed) C? All of them, except that if I'm not mistaken you are assigning to a[6], which does not exist. Enums are just a way to write integer constants, in essence. Many existing compilers may object to some part of the above, but that's a problem any time an old construct is liberalized. -- MSDOS is not dead, it just | Henry Spencer at U of Toronto Zoology smells that way. | uunet!mnetor!utzoo!henry henry@zoo.toronto.edu