Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Danlinasyr opened this issue Nov 5, 2022 · 0 comments

Comments

@Danlinasyr
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant