title: Expression must be a modifiable lvalue (pointer to struct)
body: <p>I've looked at similar questions but haven't really found an answer to my problem.</p>
  
  <p>In my program, I have a function, sortdata, as follows:</p>
  
  <pre><code>void sortdata(Person *arr[], int noElements)
  {
      /* temporary pointer to Person data type to aid with swapping */
      Person *tempptr = (Person *)malloc(sizeof(Person));
  
      int i = 0;
  
      /* loop I am working on to sort my data */
      if (arr[i]-&gt;zip &gt; arr[i + 1]-&gt;zip) 
      {
          /* stores value in index i for array inside of temporary pointer */
          tempptr-&gt;name = arr[i]-&gt;name;
      }
  }
  </code></pre>
  
  <p>I'm receiving the error described in the question at this line:</p>
  
  <pre><code>  tempptr-&gt;name = arr[i]-&gt;name;
  </code></pre>
  
  <p>temp is not recognized as a modifiable lvalue. Why is this? I have this code in another function within my program:</p>
  
  <pre><code>while ((gets(teststring)) != NULL &amp;&amp; i &lt; 50)
  {
      /* dynamically allocates memory for each index of the array */
      arr[i] = (Person*)malloc(sizeof(Person));
  
      /* takes in data from user/ input file */
  
      strcpy(arr[i]-&gt;name, teststring);
      gets(arr[i]-&gt;address);
      gets(arr[i]-&gt;citystate);
      gets(arr[i]-&gt;zip);
      printf("\n");
  }
  </code></pre>
  
  <p>I haven't previously initialized arr[] (arr[] is an array of pointers to a structure passed from elsewhere in the program).</p>
  
  <p>How do I make it so that I can store the values in arr[i] within tempptr? </p>
  
  <p>Here is my structure definition in case it is needed:</p>
  
  <pre><code>/* structure defintion with typedef */
  typedef struct person{
      char name[50];
      char address[50];
      char citystate[30];
      char zip[10];
  }Person;
  </code></pre>
  
  <p>This program is for a class assignment so while I appreciate any efforts to help, I am only concerned with how to be able to store values in tempptr so I can perform swaps. Thank you.</p>