Answers to questions on literals

  1. Why are character and string literals distinct?
    A string must have at least two characters in it (unless it is the empty string), since it is terminated by the null character. A single character constant is just the internal value for the character it represents.

    Thus "a" contains the characters 'a' and '\0'. 'a' contains just 'a'.

  2. What is the decimal value of the following?
    1. 012
      10
    2. 0x12
      18
    3. 08
      8

    Back to the questions.


    Back to the notes on literals.