E
edson
Greetings
For certain operations I would like to have easy access to struct
members. Here is an example.
struct mystruct {
char member1[3];
char member2[50];
char member3[12];
};
/* print the strings in the struct */
for(i=0; i<3; i++){
switch(i):
case 0:
printf(" %s\r\n", mystruct.member1 );
break;
case 1:
printf(" %s\r\n", mystruct.member2 );
break;
case 2:
printf(" %s\r\n", mystruct.member3 );
break;
}
This is very cumbersom, sepecially for large structs. Is there some way
I could avoid having to name each member?
something like the following pseudocode;
for(i=0; i<3; i++){
print member i
}
I would appreciate advice on this.
Regards.
For certain operations I would like to have easy access to struct
members. Here is an example.
struct mystruct {
char member1[3];
char member2[50];
char member3[12];
};
/* print the strings in the struct */
for(i=0; i<3; i++){
switch(i):
case 0:
printf(" %s\r\n", mystruct.member1 );
break;
case 1:
printf(" %s\r\n", mystruct.member2 );
break;
case 2:
printf(" %s\r\n", mystruct.member3 );
break;
}
This is very cumbersom, sepecially for large structs. Is there some way
I could avoid having to name each member?
something like the following pseudocode;
for(i=0; i<3; i++){
print member i
}
I would appreciate advice on this.
Regards.