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.