Skip to content

Instantly share code, notes, and snippets.

@theidexisted
Created May 28, 2015 02:52
Show Gist options
  • Select an option

  • Save theidexisted/e42f233e7fc2e051942d to your computer and use it in GitHub Desktop.

Select an option

Save theidexisted/e42f233e7fc2e051942d to your computer and use it in GitHub Desktop.
void foo(int argc, const char* argv[]) {
while (argc--)
std::cout << *argv++ << ' ';
}
int main()
{
std::vector<std::string> vec {"1", "2", "3", "4"};
std::vector<const char*> vecptr;
std::transform(std::begin(vec), std::end(vec), std::back_inserter(vecptr),
[](auto& s) { return s.c_str(); });
foo(vecptr.size(), &vecptr[0]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment