Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
void pointers
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Ian Collins, post: 4139344"] On 10/ 6/10 02:41 AM, steve wrote: It looks like you are trying to build a heterogeneous container. Have you considered an array of unions? Something like: typedef enum { Int, Double, String } MemberType; typedef struct { union { int intItem; double doubleItem; char* stringItem; } member; MemberType type; } Array; int main(int argc, char *argv[]) { Array array[2]; array[0].member.intItem = 42; array[0].type = Int; array[1].member.intItem = 42.42; array[1].type = Double; return 0; } [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
void pointers
Top