title: Very confused about inserting string into linked list
body: <p>I've been working on this project for over a day and I'm really confused. I pray that someone help figure this out. I'm having trouble with the function <code>insertItemList</code>. I don't know how to get the <code>String</code> in the test file into the <code>linked list</code>. This is a homework. The project is much larger than this but i dumbed it down to just what i need help with. Does anybody know what I'm doing wrong?</p>
  
  <p>List.h</p>
  
  <pre><code>       #ifndef _list_h
         #define _list_h
  
        /*
        * Defines a single list item.
        */
  
        typedef char *ListItemT;
  
        /*
        * Defines ListP to be a POINTER to a list struct.
        * (Define the list struct in the (.c) file.
        */
  
        typedef struct ListT *ListP;
  
        /*
        * Returns a pointer to a new empty list.
        * You may implement this list as a singly or doubly
        * linked list.
        */
  
        ListP newList();
  
        /*
        * Creates a new node, inserts the item into the
        * new node and inserts the new node into the list
        * after the current node.
        * Current in then moved to the newly inserted node.
        * NOTE: Impossible to insert at head of list.
        */
  
        void insertItemList(ListP, ListItemT);
  
        #endif
  </code></pre>
  
  <p>List.c</p>
  
  <pre><code>      #include &lt;stdio.h&gt;
        #include &lt;stdlib.h&gt;
        #include &lt;string.h&gt;
        #include "List.h"
  
  
        struct ListT
        { 
           char INFO[20]; 
           struct ListT *Next; 
        }*Head;
  
  
  
        /*
        * Returns a pointer to a new empty list.
        * You may implement this list as a singly or doubly
        * linked list.
        */
  
        ListP newList()
  
        {
        // allocate memory for new list 
  
        struct ListT *newnode = malloc(sizeof(struct ListT));
  
        return newnode; 
        }
  
        /*
        * Creates a new node, inserts the item into the
        * new node and inserts the new node into the list
        * after the current node.
        * Current in then moved to the newly inserted node.
        * NOTE: Impossible to insert at head of list.
        */
  
        //where I'm having trouble
  
       void insertItemList(ListP LOC, ListItemT DATA)
  
       {
       struct ListT *temp;
  
       temp=(struct ListT *)malloc(sizeof(struct ListT)); 
  
       strcpy(temp-&gt;INFO, DATA);
       }
  </code></pre>
  
  <p>ListTest.c</p>
  
  <pre><code>     #include &lt;stdio.h&gt;
       #include &lt;string.h&gt;
       #include "List.h"
  
       int main()
       {
       // Create two lists
       ListP list1 = newList();
       ListP list2 = newList();
       printf("\nList Creation Successful!\n");
  
       // Insert one name into the first list
       insertItemList( list1, "Alice" ); //Ive never seen a parameter like this before.
       }
  </code></pre>