c - Not able to obtain struct item -
given, in function called,
void callfunct1 (arg_t **q) { if (t==1) // *q = null; else memcpy((*q)->items, listofcontents, size of listofcontents); // listofcontents const static, no memcpy required }; export_symbol(callfunct1); given t == 0
how may ensure memcpy getting contents?
arg_t* q; // callfunct1 (&q); //not able obtain here (q->items) arg_t struct.
typedef struct { list items[100]; } arg_t; typedef struct { int contents; } list;
since q memory not allocated need allocate memory first forr q , copy contents q.
to memcpy address of structure should passed &((*q)->items) , source structure
(or)
change function callfunct1 (arg_t *q) , can called below
arg_t q;
callfunct1 (&q);
Comments
Post a Comment