The other answers show how to make a copy of the returned array and create a vector, but assuming the API allocates memory for the array and expects the caller to delete it, you may also want to consider sticking the array into a smart pointer and using it as is. Is Pelosi's trip to Taiwan an "official" or "unofficial" visit? I will not answer directly your question, but maybe provide some useful information. ref: https://en.cppreference.com/w/cpp/utility/functional/reference_wrapper, std::vector