Using " or ' for characters? Why the differece?

Searching for this questing was a challenge! The damn little single and double quotation marks have a function in search strings!

And to search for """ to exclude anything but " is not much of a help.

So here it goes: When writing characters, the reference list says, that single characters should be enveloped in single quotes:


while multiple characters should be in double quotes:


I realized this the hard way, when I tried writing some spaces to a logged file as:

'     '

and got numbers instead.

But as far as I can see, double quotes on a single character works too?


Why have this complication in the syntax? is not very informative.

'A' is a single character constant.
It occupies a single byte.
'AB' is a multi-character constant and occupies an int.
The only way of printing an int with "Serial.print" is to represent it as it numeric value (usually decimal), but if you print it as hex, you'll see the two distinct values 0x41 and 0x42.

And "A" is a string consisting of 2 bytes: the character 'A' and the terminating '\0' nul character.

So, single quotes create characters, double quotes create arrays of characters terminated with a '\0' (strings).

Why have this complication in the syntax?

That’s the way C did it for many years.

Some languages (eg. Lua) treat single and double quotes the same. Others (eg. PHP) have subtle differences in the way they treat them. C treats them completely differently.

You just have to learn it, sorry.

Thanks to all of you.