title: Trouble passing struct pointers in C to create a sequential list
body: <p>I have a struct defined here</p>
  
  <pre><code>typedef struct {
  char name[10];
  int idBadge;
  } Employee;
  </code></pre>
  
  <p>I want to populate one instance of this struct using this function call:</p>
  
  <pre><code>void EmployeeCall (char *name, int badgeNumber, Employee *E){
      E = (Employee *)malloc(sizeof(Employee));
      strcpy(E-&gt;name,name);
      E-&gt;idBadge = badgeNumber;
  }
  </code></pre>
  
  <p>and then, I want to retrieve a given piece of information using a call like this:</p>
  
  <pre><code>int EmployeeBadge (Employee E){
      return(E.idBadge);
  }
  </code></pre>
  
  <p>I call these functions from my Main bellow:</p>
  
  <pre><code>int main(void){
      Employee a;
      int badgeNumber;
  
      int badgeNumberA = 1028;
      char *namePtrA = "Fred";
  
      EmployeeCall( namePtrA, badgeNumberA, &amp;a );
  
      badgeNumber = EmployeeBadge(a);
      printf("%d\n",badgeNumber);
  
      return 0;
  }
  </code></pre>
  
  <p>When I call them, it all compiles correctly however, the return on EmployeeBadge is incorrect.  It returns the int as if nothing was placed into the struct; <em>badgeNumber = 32767</em></p>
  
  <p>How is it possible to create a struct variable that can be passed by both value and reference?  Would I need another Employee variable that is a pointer and assign Employee a to it for the EmployeeCall function? </p>