Re: is it possible to access members of struct in loop?
- From: Dave Thompson <david.thompson1@xxxxxxxxxxxxxxxx>
- Date: Mon, 10 Jul 2006 08:19:21 GMT
On 23 Jun 2006 00:12:02 -0700, "Erich Pul" <erich.pul@xxxxxxxxxxxx>
wrote:
hi!As others have said, no. There are two things you can do that may, or
is it possible to access the members of a struct (e.g. 10 members) in a
loop, comparable to an array?
may not, approach this closely enough for your purpose:
enum { height /* = 0 */, width /* = 1 */, depth /* etc. */, NUMDIM };
struct dims { double dim [NUMDIM /* or 3 */]; } foo;
.... volume = foo.dim[height] * foo.dim[width] * foo.dim[depth]; ...
/* best not to use simple names like height because a macro
takes the identifier 'out of play' for ALL other use */
#define d_height dim[0]
#define d_width dim[1]
#define d_depth dim[2]
#define d_NUMDIM 3
struct dims { double dim [NUMDIM]; } foo;
.... volume = foo.d_height * foo.d_width * foo.d_depth; ...
- David.Thompson1 at worldnet.att.net
.
- Prev by Date: Re: Assembly problem
- Next by Date: Re: redefine a function with a same name
- Previous by thread: Re: Assembly problem
- Next by thread: Re: redefine a function with a same name
- Index(es):
Relevant Pages
|
Loading