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
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
-
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?-
-
Contributor@stell-91Hello, can you mark the issue as resolved?
-
-
@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'
-