Q:

Write a program to assign the elements from a list of char* pointers to C-style character strings to a vector of strings

0

Write a program to assign the elements from a list of char* pointers to C-style character strings to a vector of strings.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <vector>
#include <list>
#include <string>
#include <iostream>

int main() {
  std::list<char *> lc{"aaa", "bbb", "ccc"};
  std::vector<std::string> vs;

  vs.assign(lc.begin(), lc.end());

  std::cout << vs[0] << std::endl;

  return 0;
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now