Assume that word is a variable of type string that has been assigned a value. Write an expression whose value is a string consisting of the first three characters of the value of word. So if the value of word were “dystopia” the expression’s value would be “dys”.

1
Assume that word is a variable of type string that has been assigned a value. Write an expression whose value is a string consisting of the first three characters of the value of word. So if the value of word were “dystopia” the expression’s value would be “dys”.

LANGUAGE: C++

CHALLENGE:

Assume that word is a variable of type string that has been assigned a value. Write an expression whose value is a string consisting of the first three characters of the value of word. So if the value of word were “dystopia” the expression’s value would be “dys”.

SOLUTION:



word.substr(0,3)

One comment

Add comment