title: format specifies type 'int' but the argument has type 'void *'
body: <p>I am trying to create a list struct in C, where there are 3 'elements' to the struct: the content, the datatype, and the pointer to the next element in the list. Here is the code:</p>
  
  <pre><code>struct listNode{
      void *content;
      char datatype;
      void *next;
  
  };
  typedef struct listNode listNode;
  
  void printList(listNode *item){
      while (1){
          if (item-&gt;datatype == 'i'){
              printf("%d\n", item-&gt;content);
          } else if (item-&gt;datatype == 's'){
              printf("%s\n", item-&gt;content);
          } else if (item-&gt;datatype == 'c'){
              printf("%c\n", item-&gt;content);
          } else if (item-&gt;datatype == 'f'){
              printf("%f\n", item-&gt;content);
          }
          fflush(stdout);
          if (item-&gt;next != NULL){
              item = item-&gt;next;
          }
      }
  
  
  
  
  }
  
  int main(){
  
      listNode *element1;
      listNode *element2;
      listNode *element3;
  
      element1-&gt;content = (char*) "Hello World";
      element1-&gt;datatype = 's';
      element1-&gt;next = (struct listNode *) &amp;element2;
  
      element2-&gt;content = (char*) 'z';
      element2-&gt;datatype = 'f';
      element2-&gt;next = (struct listNode *) &amp;element3;
  
      element3-&gt;content = (int *) 5;
      element3-&gt;datatype = 'i';
      element3-&gt;next = (struct listNode *) NULL;
      printList(&amp;element1);
  
  
  
      return 0;
  }
  </code></pre>
  
  <p>When I run the code, I get 4 warnings, and three of them are the warning I have put in as the title. Here is what happens when I compile the code:</p>
  
  <pre><code>listc.c:17:19: warning: format specifies type 'int' but the argument has
        type 'void *' [-Wformat]
                          printf("%d\n", item-&gt;content);
                                  ~~     ^~~~~~~~~~~~~
  listc.c:21:19: warning: format specifies type 'int' but the argument has
        type 'void *' [-Wformat]
                          printf("%c\n", item-&gt;content);
                                  ~~     ^~~~~~~~~~~~~
  listc.c:23:19: warning: format specifies type 'double' but the argument has
        type 'void *' [-Wformat]
                          printf("%f\n", item-&gt;content);
                                  ~~     ^~~~~~~~~~~~~
  listc.c:52:12: warning: incompatible pointer types passing 'listNode **'
        (aka 'struct listNode **') to parameter of type 'listNode *' (aka
        'struct listNode *'); remove &amp; [-Wincompatible-pointer-types]
          printList(&amp;element1);
                    ^~~~~~~~~
  listc.c:14:26: note: passing argument to parameter 'item' here
  void printList(listNode *item){
                           ^
  4 warnings generated.
  </code></pre>
  
  <p>When I run the code, I get the infamous <code>Segmentation fault 11</code>. Would someone please tell me how to fix the issue and all underlying problems. Also please excuse my terrible code as this is the first time I'm working with creating my own struct. Thanks!</p>