Q:

Repeat the previous program but read strings this time

0

Repeat the previous program but read strings this time.

All Answers

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

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

int main() {
  std::vector<std::string> sv;
  std::string s;
  while (std::cin >> s)
    sv.push_back(s);
  for (const auto & k : sv)
    std::cout << k << " ";
  std::cout << 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