Skip to main content

Section 20.2 Assign a New Value

Just like the variables we have previously worked with, strings can also be updated after they are initialized.

Activity 20.2.

Can you assign a new string value to firstName in the code? For example, can you use the following line?
firstName = "Alex";
Record your answer below.

Investigate 20.3.

We declare strings as arrays of type char, so is it possible to include numbers within these strings? For example, could we declare the following string?
char firstName[] = "Simon1234";