Start learning free

LESSON 58 OF 667 · STRINGS I

Updating string characters in C++

Lesson

Unlike in other languages, strings in C++ are mutable, meaning the characters can be changed freely, using indices and the bracket notation:

string message = "Hello world!";

message[5] = '_';
message[6] = 'W';

cout << message; // Output: Hello_World!

Assignment
Follow the Coding Tutorial and let's update some strings!


Hint
Look at the examples above if you get stuck.


STEP 1 OF 1
    Ctrl + Enter to check