Array of structures: printing all members of each structure
<p>I'm trying to print out all the members of each structure from a list. I was provided the print functions below to print out an element from a generic list.</p>

<p>Here is the structure definition of my list, which is in a generic list ADT c file:</p>

<pre><code>struct list_type {
  void *data;
  int size;
  int capacity;
  int elementSize;
  int (*comparePtr) (void *d1, void *d2);
};
</code></pre>

<p>So in a generic list ADT c file, I have this print function: </p>

<pre><code>// client needs to send a pointer to a function capable of printing an element
void printl(ListType listptr, void (*printItem) (void *d)) {
  int i;
  for(i = 0; i &lt; listptr-&gt;size; i++) {
    // since we cannot use data[i], we need to calculate the address
    // of the element to be sent to the client's print function
    // since data is of type void, the formula is:
    // the beginning address of the array + (offset x element size)
    printItem(listptr-&gt;data + i * (listptr-&gt;elementSize) );
    printf(" ");
  }
  printf("\n");
}
</code></pre>

<p>I call my printl function like so:</p>

<pre><code>printl(clientList, printItem);
</code></pre>

<p>In my driver file, there's a function to print out an element from the list:</p>

<pre><code>void printItem (int* p) {
    printf("%d", *p);
    //`my attempt at printing the members of an individual structure from the list
    // printf("%s", ((Client *)&amp;p)[0]); 
}
</code></pre>

<p>Here is my <code>Client</code> structure definition:</p>

<pre><code>struct client_tag {
    char id[5];
    char name[30];
    char email[30];
    char phoneNum[15];
};
</code></pre>

<p>When I run the program, I get a bunch of weird characters. How do I fix this?</p>