title: Manipulating a struct in C using functions
body: <p>I'm trying to manipulate an dynamically allocated matrix declared as global pointer using functions, for sake of simplicity I'm not gonna paste here the code but I'll provide an equivalent, and probably clearer example</p>
  
  <pre><code>structname **variable;
  
  int main()
  {
      variable = readfile("filename");
      variable = modify(variable);
      output(variable);
  }
  </code></pre>
  
  <p>This looks pretty simple, and input and output works correctly, the problem is that my "modify" function is not making any modification, this is an example of it:</p>
  
  <pre><code>structname **modify(structname **p)
  {
    swapitems(p[x][y],p[j][z]);
    modifyitem(p[x][y]);
    return p;
  }
  </code></pre>
  
  <p>with</p>
  
  <pre><code>void swapitems(structname a, structname b)
  {
       structname buffer;
  
       buffer = b;
       b = a;
       a = buffer;
  }
  </code></pre>
  
  <p>I guess the problem is that I can't pass the elements to <code>swapitems</code> and <code>modifyitem</code> like that, how can I modify items using functions like those in the <code>modify</code> ?
  (of course there are no compiling errors )</p>