Difference between ' and "

Solved
Hello,

I'm having a bit of trouble with programming because I think I don't understand the difference between " and '.
If I understand correctly, in a program when I do "x" it will display the character x as output.
But if I do 'x' what is the difference? Why use 'x'?

Thank you for your explanations

Configuration: Windows / Chrome 59.0.3071.115

1 answer

  1. Hello stell-91,

    Single quotes are for characters while double quotes are for strings.

    For example, you cannot write in C:
    'string' but you can write "string".

    In fact, the character corresponding to an integer in the ASCII table is a character, while the other is an array made up of characters.

    Did you come from a high-level language like PHP, Python, Ruby, or another?
    1. Thank you for your explanations. Just with the first two lines, I had understood. But now it's even clearer.

      No, I'm starting out.
    2. Contributor
      @stell-91Hello, can you mark the issue as resolved?
    3. To come back to what you told me "chain" is ok 'a' is fine too "a" stays good, but 'chain' is wrong?

      Do you confirm?
    4. @stell-91Yes,
      A string contains characters and a terminator:
      "chaine" is composed of the characters 'c' 'h' 'a' 'i' 'n' 'e' and the terminator denoted by '\0'
      "a" is composed of the character 'a' and the terminator '\0'
      "" is an empty string, it contains only the terminator character '\0'