Multiple choice technology programming languages

Append character to string

  1. erase

  2. copy

  3. push_back

  4. swap

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

push_back() is the standard C++ string method to append a single character to the end of the string. erase() removes characters, copy() copies a substring, and swap() exchanges two strings' contents.

AI explanation

push_back is the standard C++ std::string member function that appends a single character to the end of the string, mirroring the vector method of the same name. erase removes characters, copy copies content into a buffer, and swap exchanges contents with another string — none of them append.