std::vector stores its elements in an array. The size of that array can be read using the capacity() function. If you insert more elements than can fit in the array it will allocate a new bigger array, move the elements from the old array to the new array, and keep using the new array instead. This means the elements will be stored in a new location in memory.
If you have a known upper limit on the number of elements that you will be storing in the vector you can avoid reallocations by explicitly specifying the size of the vector's internal array using the reserve() function.
You also need to be very careful when storing the pointer returned from c_str() because it can easily be invalidated if the string is modified. Have you considered storing std::string instead of const char* inside the vector?
because of I have to pass n_vec.data() to another function which is a function at the low level of a big package, not a good idea to change it.
If I use std::string instead of const char*, it won't be compiled because of that function.
When I push a new element, all the elements I added before become the same as the new element
this seems to suggest that all the existing pointers in n_vec are reassigned upon each push_back to point to the object owned by the latest entrant and might be due to what coder777 says about temporary variables but I'm wondering in that case std::move() might have worked but ...
I also tried it with std::move, but it did not solve the problem