Welcome to Dream.In.Code
Getting C++ Help is Easy!

Join 135,948 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,707 people online right now. Registration is fast and FREE... Join Now!




Change an union nature during the execution

 
Reply to this topicStart new topic

Change an union nature during the execution

devesa
10 May, 2008 - 03:40 PM
Post #1

New D.I.C Head
*

Joined: 16 Nov, 2007
Posts: 19


My Contributions
I have a piece of code like this:

CODE
typedef struct
{
    struct Node_u *pI;
    struct Node_u *pD;
} NodeI;

typedef union
{
    NodeI nInt;
    unsigned char *data;
}Node_a;

typedef struct Node_u
{
    Node_a nodo;
    struct Node_u *pNext;
}Node;


In a function I'm working with union Node_a as a NodeI, I mean, I am using the nInt structure.
But later I will need that this union will change (in real time) to the char array, and not like an nInt. I cannot free() all the Node element because other elements will point to this union, but I do not mind if I loose *pI and *pD values. How can I do that?

Thank you so much!!
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/1/08 08:55AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month