本文共 980 字,大约阅读时间需要 3 分钟。
c语言中双引号和单引号
In you might find yourself using double quotes in some cases, and single quotes in other cases.
在您可能发现自己在某些情况下使用双引号,而在其他情况下使用单引号。
In some languages, there’s no difference between the two. But in C, there is difference, and you’ll use one vs the other depending on the need.
在某些语言中,两者之间没有区别。 但是在C语言中,存在差异,您将根据需要使用一个与另一个。
When can you use single quotes and when can you use double quotes?
什么时候可以使用单引号,什么时候可以使用双引号?
Single quotes are used to identify a single character (char
value):
单引号用于标识单个字符( char
值):
char letter = 'a';
Double quotes are used to create a string literal:
双引号用于创建字符串文字:
char *name = "Flavio";
Note that you can create a single-letter string literal:
请注意,您可以创建一个单字母字符串文字:
char *letter = "a";
But remember that a string is composed by the characters of the string, plus a 0
character at the end, which makes single-letter string literals take double the space of a single character.
但是请记住,字符串是由字符串的字符组成的,最后是一个0
字符,这使得单字母字符串文字占用的空间是单个字符的两倍。
翻译自:
c语言中双引号和单引号
转载地址:http://aomgb.baihongyu.com/