title: Swapping two structures in c
body: <p>Hi i'm trying to create a swap function that swaps the first two elements of the structure. Can someone please show me how to make this work.   </p>
  
  <pre><code>void swap(struct StudentRecord *A, struct StudentRecord *B){
      struct StudentRecord *temp = *A;
      *A = *B;
      *B = *temp;
  }
  
  
  struct StudentRecord *pSRecord[numrecords];
  
  for(int i = 0; i &lt; numrecords; i++) {
  
  pSRecord[i] = &amp;SRecords[i];
  
  }
  
  printf("%p \n", pSRecord[0]);
  printf("%p \n", pSRecord[1]);
  
  swap(&amp;pSRecord[0], &amp;pSRecord[1]);
  
  printf("%p \n", pSRecord[0]);
  printf("%p \n", pSRecord[1]);
  </code></pre>