// Copy Characters from a Vector to a String // First, we will fill the vector with characters read from the // standard input. Then, we will copy the characters. Then, we print // the string. #include #include // has EXIT_SUCCESS #include // has copy() #include #include int main() { vector v; // make a vector of characters // Store characters from standard input in the vector. char c; while (cin.get(c)) v.push_back(c); // grow vector one larger, storing c // in the last position // Copy the vector's characters. string s; // unnecessary s.resize(v.size()); copy(v.begin(), v.end(), back_inserter(s)); // copy the characters, enlarging s as we go // Print the string's characters. cout << s; return EXIT_SUCCESS; }