// Copy Characters from a String to a Vector // 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() { string s; // make a string // Store characters from standard input in the vector. char c; while (cin.get(c)) s += c; // grow string one larger, storing c // in the last position // Copy the string's characters. vector v; // unnecessary to v.resize(s.size()); copy(s.begin(), s.end(), back_inserter(v)); // copy the characters, enlarging v as we go // Print the string's characters. copy(v.begin(), v.end(), ostream_iterator(cout)); return EXIT_SUCCESS; }