"'之间'和&QUOT差异; C [英] Differences between '' and "" C
问题描述
Recentely我已经看到,如果我使用的printf
与'富',我得到一个警告。
的printf(NUMERO');
警告:字符常量太长,其类型[默认启用]
警告:传递printf式的参数1,使指针从整
没有一个演员。 /usr/include/stdio.h:362:12:注:应为常数
字符* 限制,但参数的类型为INT的extern INT的printf
(为const char * __限制__format,...);警告:格式不是字符串
文字,没有格式参数[-Wformat安全]
块引用> <;当我使用,
我没有得到任何警告的printf(NUMERO),
和/ p>
那么,有什么的区别
和
,
?解决方案在的ç,
用于字符常量和
,
字符串,不像< A HREF =/问题/标记/蟒蛇类=标签后称号=显示标记的问题'巨蟒'其中两个可以互换使用的rel =标签>蟒蛇。Recentely I have seen that if I use
printf
with 'foo' I get a warning.printf('numero');
warning: character constant too long for its type [enabled by default] warning: passing argument 1 of ‘printf’ makes pointer from integer without a cast. /usr/include/stdio.h:362:12: note: expected ‘const char * restrict’ but argument is of type ‘int’ extern int printf (const char *__restrict __format, ...); warning: format not a string literal and no format arguments [-Wformat-security]
And when I use
""
I don't get any warningsprintf("numero");
So, what's the difference between
''
and""
?解决方案In c,
''
is used for character constants and""
for string, unlike python where both can be used interchangeably.这篇关于&QUOT;'之间'和&QUOT差异; C的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!