Literals/String

Revision as of 04:28, 13 November 2007 by rosettacode>Cook (New page: {{task}} Show how to quote characters and strings. If supported, show how raw quotes (quotes where escape sequences are quoted literally) and multi-line quotes work. =={{header|C}}== In...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Show how to quote characters and strings. If supported, show how raw quotes (quotes where escape sequences are quoted literally) and multi-line quotes work.

Task
Literals/String
You are encouraged to solve this task according to the task description, using any language you may know.

C

In C, single characters are contained in single quotes.

char ch = 'z';

Strings are contained in double quotes.

char str = "hello";

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

C has no raw string feature and no way of literally quoting a string containing line breaks.

LaTeX

Since LaTeX is a markup language rather than a programming language, quotes are displayed rather than interpreted. However, quotes do deserve special mention in LaTeX. Opening (left) quotes are denoted with backquotes and closing (right) quotes are denoted with quotes. Single quotes use a single symbol and double quotes use double symbols. For example, to typeset 'a' is for "apple" in LaTeX, one would type

`a' is for ``apple''

One common mistake is to use the same symbol for opening and closing quotes, which results in the one of the quotes being backward in the output. Another common mistake is to use a double quote symbol in the input file rather than two single quotes in order to produce a double quote in the output.