What is the difference between double quote string and single quote string? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the difference between double quote string and single quote string?

10th Jan 2019, 4:54 PM
Abhishek V
6 Answers
+ 2
Asirap I'm referring to C++, also you used double quotes, and either way I'm wrong. You can't do this: string str = 'Hello'; But you can do this: string str = 'H'; So you can, but only a char. It'll store one character in the string. How about explaining it like this: Single Quotes ('): Can only hold Char Characters (i.e. 'e', '
#x27;, 'A', etc.). Double Quotes ("): Can hold multiple characters (i.e. "Hello", "e", "
amp;£ HiA", etc.).
10th Jan 2019, 5:55 PM
Rain
Rain - avatar
+ 3
It depends on the language. For example in Python there is no char, only Python's 'str'. There you can use ' and " as you wish, and there's even the possibility to use three of one kind on each end of the string.
10th Jan 2019, 5:55 PM
HonFu
HonFu - avatar
+ 2
the single quote one is called a character. It can only have one character like a digit or an alphabet or a special character like '1', 'a', '&' etc. Strings are written with double quotes. It is an array of characters. It can be a single character or many like: "a" or "abc 123".
10th Jan 2019, 5:43 PM
Asirap
+ 2
Double quote is a string, single quote is a character.You can't use string to store a single quote string. It won't compile.
10th Jan 2019, 5:44 PM
Rain
Rain - avatar
+ 2
It depends on programming language, in some programming languages such as in Java and C++, double quote pairs represent a string and single quote pairs represent a char. In some other programming languages, such as in Python, single quote pairs and double quote pairs are both used to represent a string. With no differences.
10th Jan 2019, 8:16 PM
Seb TheS
Seb TheS - avatar