Skip to content

Small modification for answer of Exercise 3.9 - mention s is a empty string #214

@Danlinasyr

Description

@Danlinasyr

Exercise information

Exercise 3.9

What does the following program do? Is it valid? If not, why not?

string s;
cout << s[0] << endl;

Question or Bug

Maybe should mention string s is empty string.

Answer was

Try to get the first element of the string. It is invalid, cause this is undefined behavior.

Answer modified

Try to get the first element of the empty string s (default initialization). It is invalid, cause this is undefined behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions