title: How do I change struct variables in a C function?
body: <p>Basically, what I am trying to do is change struct variables inside a function. Here's the code:</p>
  
  <pre><code>int weapon_equip(struct player inventory, int in) {
      int x = in - 1, y;
      int previous_wep[4];
  
      //Stores the values of the previous equipped weapon.
      for(y = 0; y &lt; 4; y++)
          previous_wep[y] = inventory.weapons[0][y];
  
      /* Since the equipped weapon has a first value of 0,
      I check if the player hasn't chosen a non-existant
      item, or that he tries to equip the weapon again.*/
      if(inventory.weapons[x][TYPE] != NULL &amp;&amp; x &gt; 0) {
          inventory.weapons[0][TYPE] = inventory.weapons[x][TYPE];
          inventory.weapons[0][MATERIAL] = inventory.weapons[x][MATERIAL];
          inventory.weapons[0][ITEM] = inventory.weapons[x][ITEM];
          inventory.weapons[0][VALUE] = inventory.weapons[x][VALUE];
  
          inventory.weapons[x][TYPE] = previous_wep[TYPE];
          inventory.weapons[x][MATERIAL] = previous_wep[MATERIAL];
          inventory.weapons[x][ITEM] = previous_wep[ITEM];
          inventory.weapons[x][VALUE] = previous_wep[VALUE];
      }
  }
  </code></pre>
  
  <p>Basically, what the function does is, it changes the first value of the selected weapon array into 0, making it equipped to the player. It swaps the places of the equipped weapon, with the selected weapon to equip.</p>
  
  <p>But the thing is - I have to change a lot of variables in the function, and all of them belong in a struct. I know how to change normal integers in a function(with pointers), but I have no idea how to do it with structure variables.</p>