int main(int argc, char argv) { int myarray[] = {1, 2, 3, 5}; std::vector<int> array(myarray, myarray + 4); std::vector<int> *p = testvector(array); std::vector<int>::const_iterator it; for(it=p->begin(); it != p->end(); ++ it) { printf("%d ", *it); } return 0; } std::vector<int> *testvector(std::vector<int> array) { return &array; } Above is my test code; what is wrong that it returned 0 0 3 5 instead of 1 2 3 5
testvectoris a copy of the array you passed in.