title: how should i add objects to my vector in C?
body: <p>commodity_list which you'll see in places of the code below, is a vector of type item, and type item has 2 vectors, one of type buyer and the other, seller. so basically what's happening is possibly that they are all sharing memory of the local object here. obviously a copy constructor in C isnt possible..so how should i approach this? btw..vector has member "void** obj". i know this would be better in C++ but i dont have that luxury</p>
  
  <pre><code>  if(b-&gt;location-&gt;commodity != NULL){
  
  
              trader s;
              s.store = b-&gt;location; 
              s.distance = i;  
  
              int index = search_items(commodity_list, b-&gt;location-&gt;commodity-&gt;name);
  
              if(index == -1){ //this is a new commodity, not found in commodity list
  
                  item it; //create a new commodity in list
                  v_init(&amp;it.sellers);
                  v_init(&amp;it.buyers); 
                  it.name = b-&gt;location-&gt;commodity-&gt;name; 
  
                  if(b-&gt;location-&gt;type == LOCATION_SELLER){
                      v_add(&amp;it.sellers, &amp;s); //add buyer/seller to list of patrons in said commodity
                  } else {
                      v_add(&amp;it.buyers, &amp;s); 
                  }
  
                  v_add(commodity_list, &amp;it); // add commodity to list of commodities
  
              } else { //add seller/buyer to existing item in the commodity list
  
                  item* it = ((item*)v_get(commodity_list, index)); 
  
                  if(b-&gt;location-&gt;type == LOCATION_SELLER){
                      v_add(&amp;it-&gt;sellers, &amp;s);
                  } else {
                      v_add(&amp;it-&gt;buyers, &amp;s);
                  } 
              }
          }
  </code></pre>