title: Records not updating in C because struct pointer isn't updating
body: <p>This is my code:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  
  typedef struct{
      char item[1000];
  } itemset;
  
  void additem(itemset* items,char* thing,unsigned long* numadded){
      memcpy(items-&gt;item,thing,1000);
      items++;(*numadded)++;
  }
  
  void showitems(itemset* items,unsigned long numitems){
      itemset* p=items;
      unsigned long count;
      for (count=1;count&lt;=numitems;count++){
          printf("%d %s\n",count,p-&gt;item);p++;
      }
  }
  
  int main(){
      itemset* myitems=calloc(1,sizeof(itemset)*10);
      itemset* itemstart=myitems;
      unsigned long added=0;
      additem(myitems,"Test",&amp;added);
      additem(myitems,"Test2",&amp;added);
      additem(myitems,"Test3",&amp;added);
      printf("Count=%d\n",added);
      showitems(itemstart,added);
      free(itemstart);
  }
  </code></pre>
  
  <p>What I'm trying to see on the screen from running this code is:</p>
  
  <pre><code>Count=3
  1 Test
  2 Test2
  3 Test3
  </code></pre>
  
  <p>But instead, I see:</p>
  
  <pre><code>Count=3
  1 Test3
  2
  3
  </code></pre>
  
  <p>Therefore my additem function isn't working correctly. I find that a fix is to add <code>myitems++;</code> right after each function call, but I'm trying to make the same behavior happen inside the additem function so that I won't have to use <code>myitems++;</code> outside of the function. What else can I do to solve this?</p>