Literals/String: Difference between revisions

Content deleted Content added
→‎{{header|C}}: example consistent with the text
Line 22: Line 22:
Strings are contained in double quotes.
Strings are contained in double quotes.


char str[] = "hello";
char str[] = "z";


This means that 'z' and "z" are different. The former is a character while the latter is a string, an array of six characters: the letters 'h', 'e', 'l', 'l', 'o', and the string-terminator null '\0'.
This means that 'z' and "z" are different. The former is a character while the latter is a string, an array of two characters: the letter 'z' and the string-terminator null '\0'.


C has no raw string feature and no way of literally quoting a string containing line breaks. C also has no built-in mechanism for expanding variables within strings.
C has no raw string feature and no way of literally quoting a string containing line breaks. C also has no built-in mechanism for expanding variables within strings.