title: passing struct pointers to functions c++
body: <p>Should be a simple question, I have a struct</p>
  
  <pre><code>struct Foo{
      float *bar;
      Foo(){
          bar = 0;
      }
  };
  </code></pre>
  
  <p>and a load function:</p>
  
  <pre><code>bool loadFoo(Foo *data){
      float nums[4] = {0,1,2,3};
      data-&gt;bar = nums;
      return true;
  };
  </code></pre>
  
  <p>And I run it like this:</p>
  
  <pre><code>void main(){
      char data;
      Foo myFoo;
      loadFoo(&amp;myFoo);
      std::cerr &lt;&lt; sizeof(myFoo.bar) &lt;&lt; "\n";
      std::cerr &lt;&lt; myFoo.bar[0] &lt;&lt; "\n";
      std::cerr &lt;&lt; myFoo.bar[1] &lt;&lt; "\n";
      std::cerr &lt;&lt; myFoo.bar[2] &lt;&lt; "\n";
      std::cerr &lt;&lt; myFoo.bar[3];
      std::cin &gt;&gt; data;
  };
  </code></pre>
  
  <p>and the output is 4 bytes for the sizeof(myFoo->bar) I thought by passing the struct to the method I could modify data->bar and since bar is, float *bar; I could make it an array since I cant specify that bar is an array because its an 'unknown size' when loaded. (when implemented the program will read in values from a file) This works fine with non pointer variables but its the pointer that I can't seem to understand.</p>
  
  <p>How do I make it so that when I pass the struct I can modify the variable pointer? </p>
  
  <p>any help would be greatly appreciated!</p>