title: Assigning a vector to a struct's vector field
body: <p>I'm not sure why this works:</p>
  
  <p>main.cpp:</p>
  
  <pre><code>int main(int argc, char * argv[]) {
      Pwm_Info tf_info;
      tf_info = get_pwm_info(library_data, motif_name);
  }
  </code></pre>
  
  <p>Gen.cpp        </p>
  
  <pre><code>        struct Pwm_Info {
      std::string motif_name;
      int width;
      std::vector &lt; double &gt; pwm;
      Pwm_Info(): motif_name(0),
      width(0),
      pwm(0) {}
  }
  TF_info;
  
  Pwm_Info get_pwm_info(std::string library_data, std::string motif_name) {
      std::vector &lt; double &gt; double_list;
      strtk::parse(pwm_block, " \n\r", double_list);
      std::cout &lt;&lt; double_list.size() &lt;&lt; std::endl;
  
      Pwm_Info TF_info;
  
      TF_info.motif_name = motif_name;
      TF_info.width = n_width;
  
      std::vector &lt; double &gt; * pointer;
      std::vector &lt; double &gt; * pointer2;
  
      pointer = &amp; TF_info.pwm;
      pointer2 = &amp; double_list; * pointer = * pointer2;
      std::cout &lt;&lt; TF_info.pwm[1] &lt;&lt; std::endl;
      TF_info.pwm = double_list;
      return TF_info;
  }
  </code></pre>
  
  <p>Previously, I removed the pointers to TF_info and double list, and just had the line:</p>
  
  <pre><code>  TF_info.pwm = double_list;
  </code></pre>
  
  <p>... which resulted in a SegFault.
  What is the point of creating and assigning the pointers (pointer and pointer2) to each other?</p>