Answers for "Write a loop to read n strings (containing no white space) from the keyboard and store them in the vector v."

C++
0

Write a loop to read n strings (containing no white space) from the keyboard and store them in the vector v.

for (int i = 0; i < n; i++)

{

   cin >> s;

   // NOTE: You cannot use push_back() here because

   // the vector has been pre-allocated and pre-initialized

   v[i] = s;

}
Posted by: Guest on April-07-2021

Code answers related to "Write a loop to read n strings (containing no white space) from the keyboard and store them in the vector v."

Browse Popular Code Answers by Language