Posts by Jaime38130 • 53 points
2 posts
-
2
votes3
answers82
viewsQ: Should I allocate the member of the date structure as well?
Assuming the following structure: typedef struct lnode{ struct lnode *next; void *data; int id; }Lnode; Let’s say I want to keep one Lnode in the heap: Lnode *exp = malloc(sizeof(*exp)); I must now…
-
3
votes1
answer66
viewsQ: Assign/Print values to void * in a structure
#include <stdio.h> typedef struct elem{ void * d; }Elem; main(){ Elem *p; Elem e; double pi = 3.14; e.d = π p->d = π printf("%f\n",p->d); printf("%f\n",e.d); } When I do…