L
lancer6238
Hi,
Is there a way to create structures dynamically? For example, I could
read from a text file the data type of each member in the structure
(perhaps using numbers to represent each type - 1 for int, 2 for char
etc), the name of the members, and how many of each type. It would
even be better if I can specify, say, 4 bits of an unsigned int is for
memberA, and 4 bits of the same unsigned int is for memberB (just like
the unsigned int ip_v:4 and unsigned int ip_hl:4 in netinet/in.h).
An example would be
input text file:
DynamicStructure
1 MemberA 1 0
2 MemberB 3 0
3 MemberC1 1 4
3 MemberC2 1 4
would create the following equivalent structure named
"DynamicStructure":
struct DynamicStructure
{
int MemberA;
char MemberB[3];
unsigned int MemberC1:4;
unsigned int MemberC2:4;
}
Thank you.
Is there a way to create structures dynamically? For example, I could
read from a text file the data type of each member in the structure
(perhaps using numbers to represent each type - 1 for int, 2 for char
etc), the name of the members, and how many of each type. It would
even be better if I can specify, say, 4 bits of an unsigned int is for
memberA, and 4 bits of the same unsigned int is for memberB (just like
the unsigned int ip_v:4 and unsigned int ip_hl:4 in netinet/in.h).
An example would be
input text file:
DynamicStructure
1 MemberA 1 0
2 MemberB 3 0
3 MemberC1 1 4
3 MemberC2 1 4
would create the following equivalent structure named
"DynamicStructure":
struct DynamicStructure
{
int MemberA;
char MemberB[3];
unsigned int MemberC1:4;
unsigned int MemberC2:4;
}
Thank you.