Skip to main content
Notice removed Reward existing answer by hb20007
Bounty Ended with dave's answer chosen by hb20007
Notice added Reward existing answer by hb20007
Bounty Started worth 50 reputation by hb20007
added the name of the symbols for easier searching
Link
user3840170
  • 25.2k
  • 4
  • 100
  • 161

Why waswere single quotes ('…') chosen for characters, and double quotes ("…") for strings?

added the name of the symbols for easier searching
Link

Why was '…'single quotes ('…') chosen for characters, and "…"double quotes ("…") for strings?

Became Hot Network Question
Source Link
hb20007
  • 661
  • 1
  • 5
  • 11

Why was '…' chosen for characters, and "…" for strings?

In C, '' is used to denote a character, while "" is used to denote a string. Why was this syntax chosen?

I tried to research this using Wikipedia’s Timeline of Programming Languages along with Rosetta Code’s reference page for strings. It seems that C was the first widespread programming language which implemented this, since in popular languages before it like Pascal, ALGOL, COBOL and FORTRAN, '' and "" were interchangeable, or only one of them was used.

I know that it might seem like an obvious choice to use '' for characters and "" for strings, but it actually isn’t. Before programming, these symbols were only used in punctuation, and there is no such rule or convention that '' should be used when quoting smaller things.

Since I found Why was `!` chosen for negation? and Why was "C:" chosen for the first hard drive partition? on this SE site, I figured that this is the right place to ask this.