String-Literals in C++.

Q20. What are string-literals in C++? What is the difference between character constants and string literals in terms of size?

Ans. A string literal is a sequence of characters surrounded by double quotes.

The difference between multicharacter character constants (which are generally used for writing octal numbers or hexadecimal numbers or ASCII numbers) and string-literals is the multicharacter character constants are treated as integers (int type) and their values are implementation (version) dependent. Whereas a string-literal is treated as array of char.

Leave a Reply

Your email address will not be published. Required fields are marked *