I have a structure (which I can not modify) which has as as it's first element a pointer of type 'void *' . This structure is designed for general linked list use, and I need the 'void *' pointer to point to another structure type. I am having trouble somewhere, either allocating memory to this pointer or casting this pointer correctly.
what I've done is as follows:
typedef struct linkedListNode
{
void * pData; /* this allows any user-defined data */
struct ListNodeTag * pLink;
} ListNodeType;
/*.........*/
ListNodeType * pcurrentnode;
AnyStructType * pstruct;
pcurrentnode->pData =
(AnySructType *)malloc(sizeof(AnySructType)*1);
*pcurrentnode->pData = *pstruct;
This ' pcurrentnode->pData' is not correctly pointing to the data that I'm trying to assign to it from 'pstruct'.
If anybody sees what is wrong, I'd very much appreciate finding out.
Thanks
what I've done is as follows:
typedef struct linkedListNode
{
void * pData; /* this allows any user-defined data */
struct ListNodeTag * pLink;
} ListNodeType;
/*.........*/
ListNodeType * pcurrentnode;
AnyStructType * pstruct;
pcurrentnode->pData =
(AnySructType *)malloc(sizeof(AnySructType)*1);
*pcurrentnode->pData = *pstruct;
This ' pcurrentnode->pData' is not correctly pointing to the data that I'm trying to assign to it from 'pstruct'.
If anybody sees what is wrong, I'd very much appreciate finding out.
Thanks