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; 

  1. 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)

  2. change function callfunct1 (arg_t *q) , can called below

    arg_t q;
    callfunct1 (&q);


Comments

Popular posts from this blog

basic authentication with http post params android -

vb.net - Virtual Keyboard commands -

How to get multiresult with multicondition in Sql Server -